首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > ASP >

ASP.NET 页面传值小结

2013-04-12 
ASP.NET 页面传值总结一、表单提交:formaction target.aspx method post name form1 input na

ASP.NET 页面传值总结

一、表单提交:

<formaction= "target.aspx" method = "post" name ="form1">

 <input name = "param1" value ="1"/>

 <input name = "param2" value ="2"/>

   </form>

   ....

   form1.submit();

   ....

这种方法一般用于html页面中,不用于asp.net中,因为asp.net的表单总是提交到自身页面。

 

二、A标签的链接方式

<Ahref="target.aspx?param1=1&param2=2">链接地址传送</A>

接收页面: string str = Request["param1"]

 

三、Session共享

发送页面:Session("param1") = "1"; 

按收页面  string str =Session("param1").ToString(); 

 

四、Application共享

发送页面: Application("param1") = "1";  

按收页面: string str = Application("param1").ToString(); 

此种方法不常使用,因为Application在一个应用程序域范围共享,所有用户可以改变及设置其值,故只应用计数器等需要全局变量的地方。

 

五、Cookie

 

六、Response.Redirect()方式

  Response.Redirect("target.aspx?param1=1&param2=2")

   接收页面: stringstr = Request["param1"]

 

七、Server.Transfer()方式。

  Server.Transfer("target.aspx?param1=1&param2=2")

   接收页面: stringstr = Request["param1"]

热点排行