码迷,mamicode.com
首页 > 其他好文 > 详细

submit

时间:2014-07-29 11:16:16      阅读:262      评论:0      收藏:0      [点我收藏+]

标签:blog   java   os   io   for   cti   代码   div   

前台<body>中的代码:

<body>
    <div id="top"> </div>
        <form id="login" name="login" action="?Action=Login" method="post">
            <div id="center">
            <div id="center_left"></div>
            <div id="center_middle">
                <div class="user">
                    <label>用户名:
                        <input type="text" name="UserName" id="UserName" />
                    </label>
                </div>
                <br />
                <div class="user">
                    <label>密 码:
                        <input type="password" name="UserPassword" id="UserPassword" />
                    </label>
                </div>
            </div>
            <div id="center_middle_right"></div>
            <div id="center_submit">
                <div class="button"> <img  id="loginin" src="images/dl.gif" width="57" height="20" onclick="document.login.submit()"/> </div>
                <div class="button"> <img  id="loginreset" src="images/cz.gif" width="57" height="20" onclick="document.login.reset()"/> </div>
            </div>
            <div id="center_right"></div>
            </div>
        </form>
    <div id="footer"></div>
</body>

通过图片的点击事件,执行form.submit()传递form中的参数。

 

后台cs代码:

 protected string Action = "";
    myBaseClass myData = new myBaseClass();
    protected class UserLoginInfo
    {
        public string UserName = "";
        public string UserPassword = "";
    }
    protected UserLoginInfo _UserLoginInfo = new UserLoginInfo();//创建对象

    protected void Page_Load(object sender, EventArgs e)
    {
        Init_WebControls();
    }

    public void Init_WebControls()
    {
        try
        {
            if (!string.IsNullOrEmpty(Request.QueryString["Action"]))//获取form的Action中的参数
            {
                Action = Request.QueryString["Action"].Trim().ToLower();//去掉空格并变小写
           前台<body>中的代码:
<body>
    <div id="top"> </div>
        <form id="login" name="login" action="?Action=Login" method="post">
            <div id="center">
            <div id="center_left"></div>
            <div id="center_middle">
                <div class="user">
                    <label>用户名:
                        <input type="text" name="UserName" id="UserName" />
                    </label>
                </div>
                <br />
                <div class="user">
                    <label>密 码:
                        <input type="password" name="UserPassword" id="UserPassword" />
                    </label>
                </div>
            </div>
            <div id="center_middle_right"></div>
            <div id="center_submit">
                <div class="button"> <img  id="loginin" src="images/dl.gif" width="57" height="20" onclick="document.login.submit()"/> </div>
                <div class="button"> <img  id="loginreset" src="images/cz.gif" width="57" height="20" onclick="document.login.reset()"/> </div>
            </div>
            <div id="center_right"></div>
            </div>
        </form>
    <div id="footer"></div>
</body>

通过图片的点击事件,执行form.submit()传递form中的参数。

 

后台cs代码:

 protected string Action = "";
    myBaseClass myData = new myBaseClass();
    protected class UserLoginInfo
    {
        public string UserName = "";
        public string UserPassword = "";
    }
    protected UserLoginInfo _UserLoginInfo = new UserLoginInfo();//创建对象

    protected void Page_Load(object sender, EventArgs e)
    {
        Init_WebControls();
    }

    public void Init_WebControls()
    {
        try
        {
            if (!string.IsNullOrEmpty(Request.QueryString["Action"]))//获取form的Action中的参数
            {
                Action = Request.QueryString["Action"].Trim().ToLower();//去掉空格并变小写
            }
            switch (Action)
            {
                case "login":
                    if (!string.IsNullOrEmpty(Request.Form["UserName"]) && !string.IsNullOrEmpty(Request.Form["UserPassWord"]))//获取form中的参数
                    {
                        _UserLoginInfo.UserName = Request.Form["UserName"].ToString();
                        _UserLoginInfo.UserPassword = Request.Form["UserPassWord"].ToString();
                        string user = "select 管理员名称,密码 from T_管理员表 where 管理员名称=‘" + _UserLoginInfo.UserName + "‘ and 密码=‘" + _UserLoginInfo.UserPassword + "‘";
                        if (myData.readDataSet(user).Tables[0].Rows.Count == 1)
                        {
                            Response.Redirect("Main.aspx", false);//防止Response.End 方法终止页的执行
                        }
                        else
                        {
                            Response.Write("<Script Language=JavaScript>alert(‘密码或用户名错误,请重试!‘);</Script>");

                        }
                    }
                    break;
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    } }
            switch (Action)
            {
                case "login":
                    if (!string.IsNullOrEmpty(Request.Form["UserName"]) && !string.IsNullOrEmpty(Request.Form["UserPassWord"]))//获取form中的参数
                    {
                        _UserLoginInfo.UserName = Request.Form["UserName"].ToString();
                        _UserLoginInfo.UserPassword = Request.Form["UserPassWord"].ToString();
                        string user = "select 管理员名称,密码 from T_管理员表 where 管理员名称=‘" + _UserLoginInfo.UserName + "‘ and 密码=‘" + _UserLoginInfo.UserPassword + "‘";
                        if (myData.readDataSet(user).Tables[0].Rows.Count == 1)
                        {
                            Response.Redirect("Main.aspx", false);//防止Response.End 方法终止页的执行
                        }
                        else
                        {
                            Response.Write("<Script Language=JavaScript>alert(‘密码或用户名错误,请重试!‘);</Script>");

                        }
                    }
                    break;
            }
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

submit,布布扣,bubuko.com

submit

标签:blog   java   os   io   for   cti   代码   div   

原文地址:http://www.cnblogs.com/qiuzhongyang/p/3874136.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!