登录按钮不能用
我在后台写了一个方法,用作登录,方法如下 private void regScript()
{
StringBuilder script = new StringBuilder(300);
script.Append("<script type='text/javascript'>");
script.Append("function userLogin(){");
script.Append("var _userName=document.getElementById('" + iptName.ClientID + "').value;");
script.Append("var _password=document.getElementById('" + iptPWD.ClientID + "').value;");
script.Append("var _test=login.userLogin(_userName+','+_password).value;");
script.Append("if(_test!='sccuess'){");
script.Append("alert('密码或用户名错误!');");
script.Append("var _pnlLogin=document.getElementById('" + pnlLogin.ClientID + "');");
script.Append("_pnlLogin.style.display='';");
script.Append("var _pnlLogout=document.getElementById('" + pnlLogout.ClientID + "');");
script.Append("_pnlLogout.style.display='none';}");
script.Append("else{var _pnlLogin=document.getElementById('" + pnlLogin.ClientID + "');");
script.Append("_pnlLogin.style.display='none';");
script.Append("var _pnlLogout=document.getElementById('" + pnlLogout.ClientID + "');");
script.Append("_pnlLogout.style.display='';");
script.Append("document.getElementById('" + lblName.ClientID + "').innerText=_userName;}");
script.Append("}");
script.Append("function userLogout(){");
script.Append("login.userOut();");
script.Append("document.getElementById('" + pnlLogin.ClientID + "').style.display='';");
script.Append("document.getElementById('" + pnlLogout.ClientID + "').style.display='none';");
script.Append("document.getElementById('" + iptName.ClientID + "').value='';");
script.Append("document.getElementById('" + iptPWD.ClientID + "').value='';}");
script.Append("</script>");
if (!this.Page.IsClientScriptBlockRegistered("client"))
{
this.Page.RegisterClientScriptBlock("client", script.ToString());
}
}
在初始时绑定:
protected void Page_Load(object sender, EventArgs e)
{
try
{//用户已经登录
userName = this.Session["userName"].ToString().Trim();
this.pnlLogin.Style.Add("display", "none");
this.pnlLogout.Style.Add("display", "");
this.lblName.Text = Session["userName"].ToString();
}
catch { }
Ajax.Utility.RegisterTypeForAjax(typeof(Controls_login));
regScript();
}
前台调用:<INPUT type="button" value="登 录" onclick="javascript:userLogin();">
可是这个登录按钮不管用,哪位大侠看出是哪里错了??