下面是全部代码,已经编译通过。
Chuandi(传递)是名字空间
WebForm1:
1@ Page language="c#" Codebehind="WebForm1.aspx.cs" _ Inherits="chuandi.WebForm1 " _
1<html>
2<head>
3<title>WebForm1</title>
4</head>
5<body>
6<form id="Form1" method="post" runat="server">
7<asp:textbox id="TextBox1" runat="server"></asp:textbox>
8<asp:button id="Button1" runat="server" text="传"></asp:button>
9</form>
10</body>
11</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:
1@ Page language="c#" Codebehind="WebForm2.aspx.cs" _ Inherits="chuandi.WebForm2" _
_ ``` @ Reference Page="WebForm1.aspx"
1_