asp.net 2 postback
asp.net 2.0 introduced crosspage postback, with it the Page.PreviousPage property.
two scenerios are considered:
crosspage postback
server.transfer
usage differences:
IbuttonControl interface exposes PostBackUrl property, simply set this page to the destination page. with asp.net 1.1 , button event handler uses server.transfer to transfer to another page.
behavior differences:
when PostBackUrl is specified, an http post is sent to the destination page (to.aspx) url. with traditional server.transfer, http post is sent to the calling page (from.aspx) itself, then proceed to the destination page.
Page.PreviousPage and HttpContext.Current.Handler in to.aspx page.
Page.PreviousPage is the replacement for HttpContext.Current.Handler in Page classes.
with both methods, the PreviousPage is set to be post-from page, with a major difference that in cross-page method, PreviousPage uses lazy loading (load only on demand), post-from page's page events are all fired before onPreRender if PreviousPage is called. where in server.transfer, all post-from page events are fired up to the event handler for that action.
In both cases, Page.PreviousPage can be used, Post-to page can distinguish whether PreviousPage is a result of cross-page postback by the PreviousPage.IsCrossPagePosdBack property.
When using crosspage postback, unlike server.transfer, Handler is obviously set to the post-to page itself. this might cause confusion as in server.transfer, Handler is set to the from.aspx page. use of HttpContext.current.Handler should be eliminated in Page classes.
server-side validation
in cases serverside page validation is required, using crosspage method, the post-from page isn't validated on serverside unless requested in post-to page. post-to page needs to validate if previouspage is valid by this.PreviousPage.Validate() and IsValid.
URL:
probably only QA would benefit from this, with crosspage postback, form is posted to post-to page, thus url is updated.
