日期:2014-05-19  浏览次数:20870 次

服务端如何读取form表单提交的数据?
例如:
现有2个页面1.aspx和2.aspx
1.aspx中 <form> </form> 中的代码
    <form   id= "Form1 "   method= "get "   action= "2.aspx? ">
        user   name: <input   type= "text "   id= "username ">   <br>
        password:   <input   type= "password "   id= "password "> <br>
        <input   type= "submit "   value= "submit ">
    </form>
问题是:2.aspx中该如何读取username   和   password   ,原理是什么?

------解决方案--------------------
真没这么想过 呵呵 jsp里面的我倒是知道 asp没学过就不知道 C#用的都是服务器端控件 根本就没这么用过! 真得好好学习学习!
帮up
------解决方案--------------------
用Server.Transfer跳转,然后在2.aspx中用FindControl方法找
------解决方案--------------------
string username=Convert.ToString(Request.Form[ "userName "]);
string password=Convert.ToString(Request.Form[ "password "]);
------解决方案--------------------
1.aspx
Server.Transfer( "2.aspx ");
2.aspx
HtmlInputText userName= (HtmlInputText)this.FindControl( "userName ");
HtmlInputPassword password= (HtmlInputPassword)this.FindControl( "password ");