Articles → .NET → Cross Page Post back

Cross Page Post back






Implementation


  1. First of all create 2 webforms one will be source and other will be destination.
  2. In the source page add a textbox and a button as shown in following code
  3. <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
    <asp:Button runat="server" Text="Navigate to other page" PostBackUrl="~/cross_page_post_back_destination.aspx" />




    Picture showing a button and a textbox in the web page

    Click to Enlarge

  4. On the destination page add following code in code behind.
  5. protected void Page_Load(object sender, EventArgs e) {
      TextBox txtName = (TextBox) PreviousPage.FindControl("txtName");
      Response.Write(txtName.Text);
    }



Output


Picture showing the navigation flow in cross page post back in asp.net

Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Wednesday, April 21, 2010
 
Updated On  -  Saturday, May 16, 2015

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250