clientscript.registerstarupscript
程序代码:
<!DOCTYPE html> <html xmlns="http://www."> <head><meta http-equiv="Content-Type" content="textml; charset=utf-8" /><title> </title></head> <body> <form method="post" action="./LandingpPage.aspx" id="form1"> <div class="aspNetHidden"> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="3Tw4SA4WZSrTCGdmdo1TDS54/TVWMWh87lnm62gsYRJR3AC5VAQF6+6ZnDnSLYNJXf2XNpQC2RhpYMdSEqv7AxC0vb0JaRM6lA8yr73R77xSQBQF8WVxokUhhf6wYFGO" /> </div> <div class="aspNetHidden"> <input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="14C49897" /> <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="U1/47TOl8WrYiuiCe/XXXcK43ukKNw82GRNzlqhyYAC1PAPweSPm4ykjZJlThQhVFapGrDQB4MuzqPlDux+9jzSW58E/KAMt7hL4N1cmuQoFrj7P6J+iWgvQamCmxALdHWC5eNH9FtCw1jeeGrGXLy8hV/qS4pfz3RRv5x9WV2ElcZxzcZqLU56Dkuz4nTl7W3qL6Kk1t4QbgEdZo0urNZt8yaK2kvtocIzkE90qjBRScFk2zMl7S2ExDbHrj9Dg" /> </div> <div> </div> <span id="Land">登陆名:</span> <input name="PrintUser" type="text" id="PrintUser" /> <p> <span id="Passwd">密码:</span> <input name="PrintPasswd" type="password" id="PrintPasswd" /> </p> <span id="Label1"> </span> <input type="submit" name="Landing" value="登陆" id="Landing" style="height: 27px" /> <p> <input type="submit" name="ModifyPwd" value="修改密码" id="ModifyPwd" /> <select name="Identify_LandingPage" id="Identify_LandingPage"> <option selected="selected" value=""></option> <option value="管理员">管理员</option> <option value="普通职工">普通职工</option> <lect> </p> <script></script> </form> </body> <ml>
程序代码:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data.SqlClient; using ModifyPwd; namespace WebApplication3 { public partial class WebForm1 : System.Web.UI.Page { public string strCnn; private string id; private string pwd; private string identify; private string id2; // 从数据库读出 private string pwd2; private string identify2; protected void Page_Load(object sender, EventArgs e) { } protected void Landing_Click1(object sender, EventArgs e) { strCnn = "data source=localhost;initial catalog=学校工资管理系统;user id=sa;" + "pwd=520524"; SqlConnection sqlCnn = new SqlConnection(); sqlCnn.ConnectionString = strCnn; sqlCnn.Open(); SqlCommand sqlcmd = sqlCnn.CreateCommand(); = "select ID,Pwd,Identify from UserName where" + " ID ='" + id + "' "; SqlDataReader sqlReader = sqlcmd.ExecuteReader(); if (sqlReader.Read()) { id2 = (string)sqlReader[0]; pwd2 = (string)sqlReader[1]; identify2 = (string)sqlReader[2]; } sqlReader.Close(); if (id == null || pwd == null) ClientScript.RegisterStartupScript(GetType(), "NullUser", "alter('请输入账号密码!')", true); if (id2 == null || pwd != pwd2) ClientScript.RegisterStartupScript(GetType(), "WrongUser", "alter('账号或者密码错误!')", true); else { if (identify2 == identify) Response.Redirect("MainPage.aspx"); else ClientScript.RegisterStartupScript(GetType(), "None", "alter('你没有这个权限!')", true); } } protected void ModifyPwd_Click(object sender, EventArgs e) { Response.Redirect("ModifyPwdPage.aspx"); } protected void PrintUser_TextChanged(object sender, EventArgs e) { id = PrintUser.Text; } protected void Identify_LandingPage_SelectedIndexChanged(object sender, EventArgs e) { identify = Identify_LandingPage.Text; } protected void PrintPasswd_TextChanged1(object sender, EventArgs e) { pwd = PrintPasswd.Text; } } }
上面是html代码,下面是asp源码,问题就是为什么clientscript会失效,就是根本不会弹出提示窗口
ps:他有执行clientscript语句,亲手调试过。