<script type="text/javascript"> </script> <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>无标题页</title> <mce:style type="text/css"><!-- #divuser { float:right } .style1 { width: 122px; } --></mce:style><style type="text/css" mce_bogus="1"> #divuser { float:right } .style1 { width: 122px; } </style> <mce:script language="javascript" type="text/javascript"><!-- var xmlHttp=false; function check() { var txtloginid=document.getElementById("txtLoginId"); if(txtloginid .value=="") { divuser.innerHTML ="请输入"; txtloginid .focus(); return false ; } try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); } catch(ex) { xmlHttp=false; } } if(!xmlHttp && typeof XMLHttpRequest!='undefined') { xmlHttp=new XMLHttpRequest(); } var url="Login.aspx?UserName="+txtloginid.value+""; xmlHttp .open("GET",url,true); xmlHttp .onreadystatechange=callback; xmlHttp .send(null); } function callback() { if(xmlHttp .readyState==4) { var txt=xmlHttp .responseText; if(txt!="true") { divuser .innerHTML="没有此用户名!"; } } } // --></mce:script> </head> <body> <form id="form1" runat="server"> <div style="position :absolute; left:40%; top :40%; width:400px; height:300"> <table > <tr> <td > <div style="width:auto">用户名:<input type="text" id="txtLoginId" maxlength="20" οnblur="check()" /></div></td> <td style="text-align:left " mce_style="text-align:left " class="style1"> <div id="divuser"></div></td> </tr> <tr> <td > <div>密 码: <input type="text" id="txtLoginPwd" maxlength="6" /></div></td> <td style="text-align:left; " mce_style="text-align:left; " class="style1"> <div id="divpwd"></div> </td> </tr> <tr> <td colspan="2"><div style="float:left" mce_style="float:left"></div> <asp:Button ID="btnLogin" runat="server" Text="登录" /> <asp:Button ID="btnCancel" runat="server" Text="取消" /> </td> </tr> </table> <br /> </div> </form> </body> </html> .csusing System; using System.Collections; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Xml.Linq; using OA.Bll; public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string username=Request["UserName"]; if (username != null) { if (UserLoginBll.checkuser(username)) { Response.Write("true"); } else { Response.Write("false"); } } } }