日韩天天综合网_野战两个奶头被亲到高潮_亚洲日韩欧美精品综合_av女人天堂污污污_视频一区**字幕无弹窗_国产亚洲欧美小视频_国内性爱精品在线免费视频_国产一级电影在线播放_日韩欧美内地福利_亚洲一二三不卡片区

ASP.NET十分有用的頁(yè)面間傳值方法_.Net教程

編輯Tag賺U幣
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!

推薦:ASP.NET生成靜態(tài)網(wǎng)頁(yè)的方法
環(huán)境:Microsoft .NET Framework SDK v1.1 OS:Windows Server 2003 中文版 ASP.Net生成靜態(tài)HTML頁(yè),在Asp中實(shí)現(xiàn)的生成靜態(tài)頁(yè)用到的FileSystemObject對(duì)象,在.Net中涉及此類(lèi)操作的是System.IO

一、目前在ASP.NET中頁(yè)面?zhèn)髦倒灿羞@么幾種方式:
1、表單提交
<form action= "target.aspx" method = "post" name = "form1">
<input name = "param1" value = "1111"/>
<input name = "param2" value = "2222"/>
</form>
....
form1.submit();
....
此種方在ASP。NET中無(wú)效,因?yàn)锳SP。NET的表單總是提交到自身頁(yè)面,如果要提交到別一頁(yè)面,需要特殊處理。
2、鏈接地址傳送
接收頁(yè)面: string str = Request["param1"]
3、Session共享
發(fā)送頁(yè)面:Session("param1") = "1111";
按收頁(yè)面 string str = Session("param1").ToString();
4、Application共享
發(fā)送頁(yè)面: Application("param1") = "1111";
按收頁(yè)面: string str = Application("param1").ToString();
此種方法不常使用,因?yàn)锳pplication在一個(gè)應(yīng)用程序域范圍共享,所有用戶可以改變及設(shè)置其值,故只應(yīng)用計(jì)數(shù)器等需要全局變量的地方。
5、Cookie
6、Response.Redirect()方式
Response.Redirect("target.aspx?param1=1111¶m2=2222")
接收頁(yè)面: string str = Request["param1"]
7、Server.Transfer()方式。
Server.Transfer("target.aspx?param1=1111¶m2=2222")
接收頁(yè)面: string str = Request["param1"]

二、如果在兩個(gè)頁(yè)面間需要大量的參數(shù)要傳傳遞,如數(shù)據(jù)查詢(xún)等頁(yè)面時(shí),用1 - 6的方法傳值及其不便,而第 7 種方法確有一獨(dú)特的優(yōu)勢(shì)!但使用該方法時(shí)需要一定的設(shè)置,現(xiàn)簡(jiǎn)單介紹一下該方法的使用方式:
以查詢(xún)數(shù)據(jù)頁(yè)面為例:
在查詢(xún)頁(yè)面中設(shè)置如下公有屬性(QueryPage.aspx):

以下為引用的內(nèi)容:
public class QueryPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox txtStaDate;
protected System.Web.UI.WebControls.TextBox txtEndDate;
...
/// <summary>
/// 開(kāi)始時(shí)間
/// </summary>
public string StaDate
{
get{ return this.txtStaDate.Text;}
set{this.txtStaDate.Text = value;}
}
/// <summary>
/// 結(jié)束時(shí)間
/// </summary>
public string EndDate
{
get{ return this.txtEndDate.Text;}
set{this.txtEndDate.Text = value;}
}
....
private void btnEnter_Click(object sender, System.EventArgs e)
{
Server.Transfer("ResultPage.aspx");
}
}

在顯示查詢(xún)結(jié)果頁(yè)面(ResultPage.aspx):

以下為引用的內(nèi)容:
public class ResultPage : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{

//轉(zhuǎn)換一下即可獲得前一頁(yè)面中輸入的數(shù)據(jù)
QueryPage queryPage = ( QueryPage )Context.Handler;

Response.Write( "StaDate:" );
Response.Write( queryPage.StaDate );
Response.Write( "<br/>EndDate:" );
Response.Write( queryPage.EndDate );
}
}

分享:如何以及為何創(chuàng)建Search .NET版
Search 開(kāi)發(fā)負(fù)責(zé)人 Larry Jordan、開(kāi)發(fā)人員 Michael Ruggiero 和 Michael Stanton 以及 .NET 框架項(xiàng)目經(jīng)理 Hari Sekhar 在暗中構(gòu)建了基于 .NET 技術(shù)的 Microsoft Web 站點(diǎn)搜索引擎新版

共3頁(yè)上一頁(yè)123下一頁(yè)
來(lái)源:模板無(wú)憂//所屬分類(lèi):.Net教程/更新時(shí)間:2008-08-22
相關(guān).Net教程