2个页面间不通过Session与url的传值方式。 选择自 syeerzy 的 Blog
2005-07-13 14:27
393 查看
下面是全部代码,已经编译通过。
Chuandi(传递)是名字空间
WebForm1:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" Inherits="chuandi.WebForm1" %>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="传"></asp:Button>
</form>
</body>
</HTML>
using System;
namespace chuandi
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
public string Text1
{
get
{
return this.TextBox1.Text;
}
}
private void Page_Load(object sender, System.EventArgs e)
{}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("WebForm2.aspx");
}
}
}
WebForm2:
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" Inherits="chuandi.WebForm2" %>
<%@ Reference Page="WebForm1.aspx" %>
<HTML>
<HEAD>
<title>WebForm2</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server">Label</asp:Label>
<asp:Button id="Button1" runat="server" Text="返回"></asp:Button>
</form>
</body>
</HTML>
using System;
namespace chuandi
{
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
public chuandi.WebForm1 wf1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
wf1=(chuandi.WebForm1)Context.Handler;
Label1.Text="上页传来的是:"+wf1.Text1;
}
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("WebForm1.aspx");
}
}
Chuandi(传递)是名字空间
WebForm1:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" Inherits="chuandi.WebForm1" %>
<HTML>
<HEAD>
<title>WebForm1</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox>
<asp:Button id="Button1" runat="server" Text="传"></asp:Button>
</form>
</body>
</HTML>
using System;
namespace chuandi
{
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Button Button1;
public string Text1
{
get
{
return this.TextBox1.Text;
}
}
private void Page_Load(object sender, System.EventArgs e)
{}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("WebForm2.aspx");
}
}
}
WebForm2:
<%@ Page language="c#" Codebehind="WebForm2.aspx.cs" Inherits="chuandi.WebForm2" %>
<%@ Reference Page="WebForm1.aspx" %>
<HTML>
<HEAD>
<title>WebForm2</title>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<asp:Label id="Label1" runat="server">Label</asp:Label>
<asp:Button id="Button1" runat="server" Text="返回"></asp:Button>
</form>
</body>
</HTML>
using System;
namespace chuandi
{
public class WebForm2 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Label Label1;
public chuandi.WebForm1 wf1;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
wf1=(chuandi.WebForm1)Context.Handler;
Label1.Text="上页传来的是:"+wf1.Text1;
}
}
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
}
private void InitializeComponent()
{
this.Button1.Click += new System.EventHandler(this.Button1_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
private void Button1_Click(object sender, System.EventArgs e)
{
Server.Transfer("WebForm1.aspx");
}
}
相关文章推荐
- 2个页面间不通过Session与url的传值方式。
- 2个页面间不通过Session与url的传值方式(转)
- 2个页面间不通过Session与url的传值方式
- 2个页面间不通过Session与url的传值方式
- Spring MVC中redirect到一个页面,同时带些信息过去进行显示,但是不通过Session方式及URL方式
- 通过url方式传参jsp页面中文乱码
- 在一个jsp页面接收另一个jsp页面通过URL方式传过来的参数
- Asp.net页面之间通过脚本传递数据 选择自 hushan518 的 Blog
- 通过http请求获取指定url的页面
- 从a站点跳转到b站点,通过url的参数判断是否让该用户选择身份
- 将html中的<input type="file" />(选择文件) 元素隐藏,并通过其它方式触发点击。file input 美化
- 基于 session 和基于 token 的用户认证方式到底该如何选择
- javascript通过url向jsp页面传递中文参数乱码解决方法
- JSP页面选择显示(通过和script嵌入作用)
- 使用iframe如何通过url传参把数据从一个页面传到另一个页面(contentWindow)
- JAVA通过访问页面中的URL实现Http文件下载到本地
- WebLogic 通过数据库的方式实现Session共享的配置
- jsp页面向action通过get方式传参,出现乱码的处理办法
- 通过Z-BlogPHP程序快速在论坛里搭建一个博客页面