日期:2014-05-17  浏览次数:20463 次

奇怪的的问题,前台的input,type为button,调用后台事件没有反应
前台代码:
HTML code
<input id="Button1" type="Button" value="" runat="server" onserverclick="Login_click" style="background:url(images_login/dl.gif); border-style:none; width:49px; height:18px; background-repeat:no-repeat;"  />


后台事件:
C# code
protected void Login_click(object sender, EventArgs e)
    {
        string user = Request.Form["textfield"].ToString();
        string pwd = Request.Form["textfield2"].ToString();

        UM.userName = user;
        if(UB.users_Query_by_Name_exist(UM))
        {
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('用户不存在!');</script>");
        }
        else
        {
            DataSet ds = UB.users_QueryUserDetail_by_Name(UM);
            string EnPwd = ds.Tables[0].Rows[0]["password"].ToString();  //解密前的密码
            string DePwd = DESEncrypt.Decrypt(EnPwd);                    //解密后的密码

            if(DePwd!=pwd)
            {
                Page.ClientScript.RegisterStartupScript(Page.GetType(), "message", "<script language='javascript' defer>alert('密码错误,请重试!');</script>");
            }
            else
            {
                Session["user"] = user;

                Response.Redirect("Admin_Index.html");
            }
        }
    }


顺便帮我看一下我这样判断登录并且session传值的方法好吗?有没有更好的方法

------解决方案--------------------
HTML code
    <form id="form1" runat="server">
    <div>
        <input id="btnLogin" type="Button" value="登录" runat="server" onserverclick="Login_click" />
    </div>
    </form>