Server. Transfer page Jump transfer control is worth the solution

Source: Internet
Author: User

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 );
}
}
}

 

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.