读书人

服务端怎么读取form表单提交的数据

发布时间: 2012-01-03 22:16:06 作者: rapoo

服务端如何读取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 ");


读书人网 >C#

热点推荐