We can see this problem on csdn today. We have provided a solution for your reference.
Problem description: On the default2.aspx page, click the button to pass the textbox1 control value to the default3.aspx page for use on the defa3.3.aspx page.
There are two key points:
1. server. Transfer ("default3.aspx", true); // The second parameter of the method is true.
2. Add a reference for the jump page class to the header of the page to jump to. <% @ reference page = "default2.aspx" %> If defa2.2.aspx is in a folder, for example, in the admin folder, enter <% @ reference page = "admin_default2.aspx" %> (that is, the complete Class Name of the CS file in the background of the page class. Pay special attention to this)
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default2.aspx. cs" inherits = "default2" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<Asp: textbox id = "textbox1" runat = "server"> </ASP: textbox>
<Asp: button id = "button1" runat = "server" text = "button" onclick = "button#click"/>
</Div>
</Form>
</Body>
</Html>
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Public partial class default2: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
}
Public string name
{
Get
{
Return textbox1.text;
}
}
Protected void button#click (Object sender, eventargs E)
{
Server. Transfer ("default3.aspx", true );
}
}
========================================================== ========================================
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default3.aspx. cs" inherits = "default3" %>
<% @ Reference page = "default2.aspx" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
</Div>
</Form>
</Body>
</Html>
Using system;
Using system. Collections. Generic;
Using system. LINQ;
Using system. Web;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Public partial class default3: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
If (! Ispostback)
{
String strtxt = "";
Default2 oform = (default2) This. Context. Handler;
Strtxt + = "the value in the textbox1 text box on the default2 page is:" + oform. Name + "<br> ";
Response. Write (strtxt );
}
}
}