Page 1: prev_firstpage.aspx <% @ Page Language = "C #" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<SCRIPT runat = "server">
Public String Username
{
Get {return this.txt name. Text ;}
}
Protected void button#click (Object sender, eventargs E)
{
Label1.text = "PostBack from self. Your name is:" + txtname. text;
}
</SCRIPT>
<HTML xmlns = "http://www.w3.org/1999/xHTML">
<Head runat = "server">
<Meta content = "text/JScript" http-equiv = "content-script-type"/>
<Title> first page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<H3>
The frist page Your name:
<Asp: textbox id = "txtname" runat = "server"/>
<Asp: Label id = "label1" runat = "server" enableviewstate = "false"/> <br/>
<Br/>
<Asp: button id = "button1" runat = "server" text = "PostBack to same page"
Onclick = "button#click"/> <br/>
<Br/>
<Asp: button id = "button2" runat = "server" text = "PostBack to second page"
Postbackurl = "prev_secondpage.aspx"/> <br/>
</Div>
</Form>
</Body>
</Html>
Page 2: prev_secondpage.aspx <% @ Page Language = "C #" %>
<% @ Previouspagetype virtualpath = "prev_firstpage.aspx" %>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<SCRIPT runat = "server">
Protected void page_load (Object sender, eventargs E)
{
This. label1.text = "Your name is:" + previouspage. Username;
}
</SCRIPT>
<HTML xmlns = "http://www.w3.org/1999/xHTML">
<Head runat = "server">
<Title> second page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
<H1>
This is the second page <P>
<Asp: Label id = "label1" runat = "server"> </ASP: Label> </P>
</Div>
</Form>
</Body>
</Html>