What is cross page posting?
By default, button controls in ASP.NET pages post back to the same page that contains
the button, where you can write an event handler for the post. In most cases this is the
desired behavior, but occasionaly you will also want to be able to post to another page in
your application. The Server.Transfer method can be used to move between pages, however
the URL doesn’t change. Instead, the cross page posting feature in ASP.NET 2.0 allows
you to fire a normal post back to a different page in the application. In the target page,
you can then access the values of server controls in the source page that initiated the post
back.
To use cross page posting, you can set the PostBackUrl property of a Button, LinkButton
or ImageButton control, which specifies the target page. In the target page, you can then
access the PreviousPage property to retrieve values from the source page. By default, the
PreviousPage property is of type Page, so you must access controls using the FindControl
method. You can also enable strongly-typed access to the source page by setting the
@PreviousPageType directive in the target page to the virtual path or Type name of the
source page.
Here is a step-by-step guide for implementing the cross-page post back using controls that implement the IButtonControl interface.
? Create a Web Form and insert a Button control on it using the VS .NET designer.
? Set the button’s PostBackUrl property to the Web Form you want to post back. For
instance in this case it is “nextpage.aspx”
<asp:Button runat=”server”
PostBackUrl=”~/nextpage.aspx” Text=”Post to nextpage” />
When the PostBackUrl property of the IButtonControl is set, the ASP.NET framework
binds the corresponding HTML element to new JavaScript function named
WebForm_DoPostBackWithOptions. The corresponding HTML rendered by the ASP.NET
2.0 will look like this:
<input name=”Button1″ value=”Post to Page 2″
onclick=”javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions(“Button1″, “,false”,”Page2.aspx”, false, false))” />
| Print article | This entry was posted by on December 5, 2009 at 1:31 pm, and is filed under Caching Concepts, Dot Net. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |


about 1 year ago
Hi im new to this. I came upon this forum I have found It amply helpful and it’s helped me loads. I should be able to give something back & support other users like it has helped me.
Thanks, Catch You Later
about 1 year ago
Howdy im new on here. I came upon this forum I have found It very accessible and its helped me a lot. I should be able to give something back and help others like its helped me.
Thank You, See You Around
about 1 year ago
Hi every body, swell chat board I have found It incredibly useful and it’s helped me out a lot
I hope to be able to contribute and support other users like this board has helped me
about 1 year ago
Hello i am new here, I hit upon this board I find It extremely useful and its helped me so much. I should be able to give something back & help other people like it has helped me.
Thanks, See You Around
about 1 year ago
Heya im new on here. I stumbled upon this board I have found It amply accessible & it’s helped me tons. I hope to contribute & assist others like it has helped me.
Thank’s, Catch You About.
about 1 year ago
just wanted to say that this website is realy great and I’m happy that i found it
I’ve gotten exposed to quite a lot of information here and just wanted to give my 4 cents. Im about to write a great article for this forum about
and I’ll publish it as soon as i complete it.
Thank you.
cheers!