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