Articles → .NET → Cross Page Post Back
Cross Page Post Back
Implementation
- First of all create 2 webforms one will be source and other will be destination.
- In the source page add a textbox and a button as shown in following code
<asp:TextBox ID="txtName" runat="server"></asp:TextBox>
<asp:Button runat="server" Text="Navigate to other page" PostBackUrl="~/cross_page_post_back_destination.aspx" />
Click to Enlarge
- On the destination page add following code in code behind.
protected void Page_Load(object sender, EventArgs e) {
TextBox txtName = (TextBox) PreviousPage.FindControl("txtName");
Response.Write(txtName.Text);
}
Output
Click to Enlarge