一、目前在ASP.NET中頁面傳值共有這麼幾種方式:
1、表單提交,
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
form1.submit();
....
此種方在ASP。NET中無效,因為ASP。NET的表單總是提交到自身頁面,如果要提交到別一頁面,需要特殊處理。
2、連結地址傳送
接收頁面: string str = Request["param1"]
3、Session共用
發送頁面:Session("param1") = "1111";
按收頁面 string str = Session("param1").ToString();
4、Application共用
發送頁面: Application("param1") = "1111";
按收頁面: string str = Application("param1").ToString();
此種方法不常使用,因為Application在一個應用程式定義域範圍共用,所有使用者可以改變及設定其值,故只應用計數器等需要全域變數的地方。
5、Cookie
6、Response.Redirect()方式
Response.Redirect("target.aspx?param1=1111?m2=2222")
接收頁面: string str = Request["param1"]
7、Server.Transfer()方式。
Server.Transfer("target.aspx?param1=1111?m2=2222")
接收頁面: string str = Request["param1"]
如果在兩個頁面間需要大量的參數要傳傳遞,如資料查詢等頁面時,用1 - 6的方法傳值及其不便,而第 7 種方法確有一獨特的優勢!但使用該方法時需要一定的設定
http://www.cnblogs.com/jetxia/archive/2007/03/22/683805.html