Here is the entire code, which has been compiled through.
Chuandi (pass) is the name space
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= "Chuan" ></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= "Back" ></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= "came on the page is:" +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");
}
}