< table style ="border:solid 1px #EDEDED;height:112px;width:211px;left: 463px; top: 257px; text-align: center;" >
< tr >
< td >
< table id ="tblLogin" border ="0" cellpadding ="0" style ="border-collapse: collapse" width ="100%" >
< tr >
< td style ="width: 62px; text-align: center; height: 37px; padding-top: 5px;" >
用户名: </ td >
< td >
< asp:TextBox ID ="tbUser" CssClass ="tb20" runat ="server" Font-Size ="0.8em" MaxLength ="20"
Style ="font-size: 12px" Width ="120px" ></ asp:TextBox >
</ td >
</ tr >
< tr >
< td style ="width: 62px; text-align: center; padding-top: 5px;" >
密 码: </ td >
< td >
< asp:TextBox ID ="tbPass" CssClass ="tb20" runat ="server" Font-Size ="0.8em" MaxLength ="20"
Style ="font-size: 12px" TextMode ="Password" Width ="120px" ></ asp:TextBox >
</ td >
</ tr >
< tr >
< td colspan ="2" style ="text-align: center;padding:5px;" >
< input type ="button" id ="btnLogin" class ="btn5" value =" 登 录 " onclick ="return login();" /></ td >
</ tr >
</ table >
< div id ="msg" style ="color:#f00;font-weight:bold;height:15px;" ></ div >
</ td >
</ tr >
</ table >
< script type ="text/javascript" language ="javascript" >
<!--
$( " #<%=tbUser.ClientID %> " ).focus();
function login()
{
var u = $( " #<%=tbUser.ClientID %> " ).val();
var p = $( " #<%=tbPass.ClientID %> " ).val();
$.ajax({
// 定义是post传递
type: " POST " ,
// 要传值到的aciton
url: " Login.aspx " ,
// 跟上要传的参数名和值
data: " t=login&u= " + u + " &p= " + p,
// 当ajax发生错误的时候
error: function () {
alert( " error " );
},
// 当ajax成功的时候
success: function (msg) {
var a = msg.substring( 0 , 1 );
var b = msg.substring( 2 , msg.length);
if (a == " 1 " ) {
$( " #msg " ).html(b);
$( " #tblLogin " ).css({ " display " : " none " });
window.top.location.href = " default.aspx " ;
}
else {
$( " #msg " ).html(b);
$( " #btnLogin " ).removeAttr( " disabled " );
$( " #<%=tbUser.ClientID %> " ).focus();
}
}
});
}
document.onkeydown = function (event){
e = event ? event :(window.event ? window.event : null );
if (e.keyCode == 13 ){
$( " #msg " ).html( " 正在登录 …… " );
$( " #btnLogin " ).focus();
$( " #btnLogin " ).attr( " disabled " , true );
login();
}
}
// -->
</ script >
后台代码返回字符串格式为string.Format("0,{0}", "用户名不能为空!");