asp.net 使用action


1、新建ActionTest.aspx页面;
2、前台代码:
<form id="form1" action="ActionTest.aspx?flag=login" runat="server" >
    <div>
    用户名:
    <input type="text" name="userName" />
    <br />
    密码:
    <input type="password"  name="password" />
    <br />
    <input type="submit"  value="登录" />
    </div>
    </form>

3、后台代码:
protected void Page_Load(object sender, EventArgs e)
        {
            object flag = Request["flag"];
            object name = Request["userName"];
            object passwordObj = Request["password"];
            if (flag != null && flag.ToString() == "login")
            {
                if (name != null)
                {
                    string userName = Request["userName"].ToString(); //获取用户名控件的值
                }
                if (passwordObj != null)
                {
                    string password = passwordObj.ToString();
                }
            }
        }

在Page_Load事件获取值;

展开阅读全文

没有更多推荐了,返回首页