-----------------------------------------------------------

New Message on MumbaiUserGroup

-----------------------------------------------------------
From: Swapnil_B1
Message 1 in Discussion

  
Cross Page PostBack 
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 occassionaly 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 postback 
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. Note that if you intend for multiple pages to post to a single target 
page, you cannot use the strongly-typed accessor (leave the PreviousPage 
directive unset).
 
Cross page posting works by the following technique: 
Cross page posting sets action of the form in Page 1 
When the Button is clicked, the post goes from Page 1 to Page 2 
Page 2 retains viewstate from Page 1 
When PreviousPage accessed, viewstate is re-populated to an instance of Page 1 
Page 1 then executes up to its LoadComplete phase (excludes rendering)  
At this point, Page 2 may access the values of controls in Page 1 
Because Page 1 will execute (up to LoadComplete) in response to a cross-page 
post, it is sometimes necessary to special-case code in the page to only 
execute when the request is not a cross-page post, but a normal request to Page 
1 instead. You may use the IsCrossPagePostBack property in Page 1 to handle 
this situation. 
If Not Page.IsCrossPagePostBack Then 
    ' handle a normal request 
End If
You can also post back to another application, however the PreviousPage 
property is null in this case. You can also transfer in code, while still 
preserving viewstate through the PreviousPage property using 
Server.Transfer(IHttpHandler, preserveViewState). 
Swapnil (Swaps) 
http://swapsnet.spaces.live.com/

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/MumbaiUserGroup/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to