当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 2个页面间不通过Session与url的传值方式

ASP.NET
asp.net(c#)网页跳转七种方法小结
完美解决在ModalPopupExtender中使用CalendarExtender时被层遮挡的问题
ASP.NET、SharePoint中另存文件的长文件名被截断的原因及解决办法
查看Json输出的*最方便*的方法 (转)
asp.net 代码隐藏的编码模型
ajaxpro.dll 控件实现异步刷新页面
asp.net DbProviderFactory的使用-示例
一个简单的asp.net 单点登录实现
jQuery+Ajax用户登录功能的实现
asp.net 弹出对话框返回多个值
.NET 中英文混合验证码实现代码
一个完整的ASP.NET 2.0 URL重写方案[翻译]
asp.net关于onpropertychange和oninput事件实现代码
asp.net gridview指定某一列滚动
Equals和==的区别 公共变量和属性的区别小结
asp.net 合并GridView中某列相同信息的行(单元格)
ASP.NET(C#) 定时执行一段代码
asp.net 预防SQL注入攻击之我见
asp.net下将Excel转成XML档的实现代码
asp.net url分页类代码

ASP.NET 中的 2个页面间不通过Session与url的传值方式


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 65 ::
收藏到网摘: n/a

下面是全部代码,已经编译通过。
Chuandi(传递)是名字空间

WebForm1:
<%@Pagelanguage="c#"Codebehind="WebForm1.aspx.cs"Inherits="chuandi.WebForm1"%>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body>
<formid="Form1"method="post"runat="server">
<asp:TextBoxid="TextBox1"runat="server"></asp:TextBox>
<asp:Buttonid="Button1"runat="server"Text="传"></asp:Button>
</form>
</body>
</HTML>
usingSystem;
namespacechuandi
{
publicclassWebForm1:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.TextBoxTextBox1;
protectedSystem.Web.UI.WebControls.ButtonButton1;
publicstringText1
{
get
{
returnthis.TextBox1.Text;
}
}
privatevoidPage_Load(objectsender,System.EventArgse)
{}
overrideprotectedvoidOnInit(EventArgse)
{
InitializeComponent();
base.OnInit(e);
}
privatevoidInitializeComponent()
{
this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);
}
privatevoidButton1_Click(objectsender,System.EventArgse)
{
Server.Transfer("WebForm2.aspx");
}
}
}


WebForm2:
<%@Pagelanguage="c#"Codebehind="WebForm2.aspx.cs"Inherits="chuandi.WebForm2"%>
<%@ReferencePage="WebForm1.aspx"%>
<HTML>
<HEAD>
<title>WebForm2</title>
</HEAD>
<body>
<formid="Form1"method="post"runat="server">
<asp:Labelid="Label1"runat="server">Label</asp:Label>
<asp:Buttonid="Button1"runat="server"Text="返回"></asp:Button>
</form>
</body>
</HTML>
usingSystem;
namespacechuandi
{
publicclassWebForm2:System.Web.UI.Page
{
protectedSystem.Web.UI.WebControls.ButtonButton1;
protectedSystem.Web.UI.WebControls.LabelLabel1;
publicchuandi.WebForm1wf1;
privatevoidPage_Load(objectsender,System.EventArgse)
{
if(!IsPostBack)
{
wf1=(chuandi.WebForm1)Context.Handler;
Label1.Text="上页传来的是:"+wf1.Text1;
}
}
overrideprotectedvoidOnInit(EventArgse)
{
InitializeComponent();
base.OnInit(e);
}
privatevoidInitializeComponent()
{
this.Button1.Click+=newSystem.EventHandler(this.Button1_Click);
this.Load+=newSystem.EventHandler(this.Page_Load);
}
privatevoidButton1_Click(objectsender,System.EventArgse)
{
Server.Transfer("WebForm1.aspx");
}
}