Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Managing State by Using Cross-Page Posting

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 483
    Comment on it

    Managing State by Using Cross-Page Posting

    By default, a Button control on a Web page submits the page back to itself. However, sometimes, you may want to post one page to another. In such a case, you can set the PostBackUrl property of the Button control to the URL of the target page. This posting of information from one page to another page is called cross-page posting. When the source page is posted to the target page, the target page must be able to access the information stored in the controls on the source page. In addition, the target page must be able to identify whether the page was loaded as a result of a cross-page postback. Accessing Information Stored in Controls on the Source Page

    The Page class exposes a public property named PreviousPage. If the source and target pages are in the same application, the PreviousPage property contains a reference to the source page. However, if the pages are in different applications, or if the page is not the target of a cross-page posting, the PreviousPage property is not initialized. You can access the values in the controls on the source page by using the FindControlmethod, as shown in the following example:

     if(PreviousPage!=null) 
     {
            TextBoxt=(TextBox)PreviousPage.FindControl("TextBox1");
    
         if(t!=null)
           {
           Response.Write(t.Text);
           }
       }
    

    In the preceding example, the value of the TextBox1 control, which is on the source page, is accessed in the target page.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: