The two pages do not pass the Session and url values.

Source: Internet
Author: User

The following is all the code that has been compiled.
Chuandi (PASS) is the namespace

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. button#click );
This. Load + = new System. EventHandler (this. Page_Load );
}
Private void button#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 = "the above page is:" + wf1.Text1;
}
}
Override protected void OnInit (EventArgs e)
{
InitializeComponent ();
Base. OnInit (e );
}
Private void InitializeComponent ()
{
This. Button1.Click + = new System. EventHandler (this. button#click );
This. Load + = new System. EventHandler (this. Page_Load );
}
Private void button#click (object sender, System. EventArgs e)
{
Server. Transfer ("WebForm1.aspx ");
}
}

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.