Cross-page transfer (2)

Source: Internet
Author: User

Method 2

To process properties in default. aspx, The previouspage attribute of default. aspx must be strongly typed. Therefore, use the previouspagetype command. This new command allows you to use the virtualpath attribute to point to default. aspx. Then, you can view the defalut. aspx attribute in the previouspage attribute through intelliisense.

Default. aspx
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "default" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.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 = "button2" runat = "server" text = "Submit page to default2.aspx" postbackurl = "~ /Default2.aspx "/>
</Div>
</Form>
</Body>
</Html>

Default. aspx. CS
Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class default: system. Web. UI. Page
{
Public textbox name
{
Get
{
Return textbox1;
}
}

Protected void page_load (Object sender, eventargs E)
{

}
}

Default2.aspx
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default2.aspx. cs" inherits = "default2" %>
<% @ Previouspagetype virtualpath = "~ /Default. 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>
<Asp: Label id = "label1" runat = "server" text = ""> </ASP: Label>
</Div>
</Form>
</Body>
</Html>

Default2.aspx. CS
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class default2: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Label1.text = "hello" + previouspage. Name. text;
}
}

Reference books ASP. NET 2.0 advanced programming (version 4th) p62

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.