Cross-page posting. Is it a good pratice to use PreviousPage in

I found this article on MSDN talking about Cross-page posting.

I never worked with Page.PreviousPage. But I think its interesting.

Do you use it? Is it a good pratice, or a bad idea?

What do you think about?



Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

The cross page posting is a helper to post some data to a different page and still have the code behind functionality.

Why is this exist ? because have a limitation of one and only form per page. But actually to an html page you can have many forms and many different post to different pages.

So to give a tool to that case, is let you set a second page to post the data, and you setup this on the Button (and not by placing second form), and from there is solve this issue, to post the data to a different page.

For example… with out and with simple html on a page you can do that.

<form method="post" action="samepage.html">
   Username: <input type="text" name="user" />
   <input type="submit" value="Submit" />

<form method="post" action="page_b.html">
   email for news letter: <input type="text" name="email" />
   <input type="submit" value="Submit" />

To solve a situation like this, and because not allow two forms at the same page, gives this option.
<form id="form1" runat="server">
Username: <asp:TextBox runat="server" ID="Name" />
<asp:Button runat="server"/>

email for news letter: <asp:TextBox runat="server" ID="email" />
<asp:Button runat="server" PostBackUrl="page_b.aspx" />


In the second case, you have one form, but you set the PostBackUrl to a different page, and from there still handle the data on code behind direct on a second page (with out redirect).

I hope this example gives you and an idea where to really use the previous page. Also what is more usually is the Redirect, how ever there are case that you need to have the result to a different page. So its per case if you use it or not.

All methods was sourced from or, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Notify of

Inline Feedbacks
View all comments
Would love your thoughts, please comment.x