top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is Cross Page Posting?

+4 votes
410 views
What is Cross Page Posting?
posted Jan 29, 2015 by Khusboo

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote
 
Best answer

Basically, cross-page posting means that you are posting form data to another page as opposed to posting form data back to the same page (as is the default in ASP.NET). This can be useful when you want to post data to another page and don't want to incur the overhead of reloading the current page simply to redirect the user to another page via an HTTP 302 (i.e. Response.Redirect).

For a more information please see Cross-Page Posting in ASP.NET Web Pages i.e. http://msdn.microsoft.com/en-us/library/ms178139.aspx

answer Jan 29, 2015 by Vikram Luthra
+1 vote

ASP.NET by default submit the forms to the same pages, cross page posting is submitted the form to a different page. This is usually required when you are creating a multipage form to collect information from the user on each page. when moving from the source to the target page.

"To use cross-page posting, you have to use the "postBackUrl" attribute to specify the page we want to post".

Example

Step 1: Add two webform "default.aspx" and "default2.aspx"

Step 2: On default.aspx, drop down a button & set textproperty of this button as targetpage.

Set the "postbackurl" property of a button to the url targetpage, default2.aspx.

Step 3: On default2.aspx drop down a lable.

Step 4: In the page load event of default2.aspx

We can access "previouspage" property to check if the page is bring accessed as cross page postback.

proctected void page_load( object sender , eventArgs e)
{
     if( page.previouspage ! =null)
    {
    }
}

Step 5: To redirect the value from the source page you must access control using the "findcontrol()" method of the the previouspage

we will accessing the text propertyof the button control in "default.aspx"

proctected void page_load( object sender , eventArgs e)
{
    if(page.previouspage !=null)
   {
        button btn = (button)(page.previouspage.findcontrol(button1));
        lable1.text =btn.text;
    }
} 

Step 6: Right click on default.aspx and set s start page

Now run application and click button we will see that the page is posting to default2.aspx.

answer Feb 4, 2015 by Manikandan J
...