PreviousPage Type
Hi , we already seen the CrossPage Posting so now we are going to see the concept Previouspage ( to send data from one page to another page )
in the first page ie: Webform1.aspx
<asp:TextBox ID="TextBox1" Text="xxxx" runat="server" />
<asp:LinkButton ID="LinkButton1" runat="server" Text="L”schen" PostBackUrl="~/webform2.aspx" />
On Webform2.aspx you have to write it on page Directive, you have to specify the page so from that page you can get the textbox value to this page. In the Virtualpath you should specify the Previous page name from where you get the control value.
<%@ PreviousPageType VirtualPath="~/Webform1.aspx" %>
on Codebehind ie: Page_load event write this
if (Page.PreviousPage != null)
{
TextBox oTextBox = (TextBox)Page.PreviousPage.FindControl("TextBox1");
if (oTextBox != null)
{
Response.Write(oTextBox.Text);
}
}
Read more »