Cross page posting
New feature in Asp.net 2.0
Why? When?
Some pages need to post the page to other page (like good old systems or old classic asp) or when there is a need to have multiple submit button controls, where one may need to submit to other page.
Who decides?
It is mostly the developer that decides to use this feature or not.
It is heavy duty control and be careful to use this feature.
How to use it?
Please refer MSFT article first.
http://msdn.microsoft.com/en-us/library/ms178139.aspx
http://msdn.microsoft.com/en-us/library/ms178140(VS.80).aspx
Secondly use strong typing both at control level and page level attributes.
PreviousPage != null && PreviousPage.IsCrossPagePostBack
Login LoginControl = (Login)PreviousPage.FindControl("Login1");
<%@ PreviousPageType VirtualPath="~/SourcePage.aspx" %>
Example of scenarios to use cross page posting
- We can have search control in the header and a regular form in the content page.
- We have to submit to different page based on a button type clicked.
- To better use of caching some times, we provide forms say for search, in one page and submit to other page ...
- For those who like old style of submitting to different pages ... like in classic asp
Note: It is all deponds the scenario, developer to decide why we need this feature.
For ex: One of the project, application site home page needs to be served very fast and I decided to use by enabling the cache (vary by browser) and did the cross page posting to validate the login information. The reason in my case are the login process is complicated with lot of server validation, roles assignment, license verification, rules and redirection ...
Drawbacks
Say, if you are validating a form on server side, it is hard to get back to the previous page.