1 / 8

Cross-page Postbacks

Cross-page Postbacks. Cross-Page Posting (Introduction 1). You can use a HyperLink control to create a link to another page Any Button control can be used for cross-page postbacks Set the PostBackURL property to the desired Web page. Cross-Page Posting (Introduction 2).

loren
Download Presentation

Cross-page Postbacks

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Cross-page Postbacks

  2. Cross-Page Posting (Introduction 1) • You can use a HyperLink control to create a link to another page • Any Button control can be used for cross-page postbacks • Set the PostBackURL property to the desired Web page

  3. Cross-Page Posting (Introduction 2) • Use the Server.Transfer method • The target page is passed as an argument • Any code following Server.Transfer is not executed • All work is done in the context of the server Server.Transfer(“DestinationPage.aspx”);

  4. Cross-Page Posting (Getting Data from the Previous Page) • The PreviousPage property of the Page object contains a reference to the page that caused the postback • This property allows you to get at the controls from the previous form (page) and their values • This is magically accomplished through viewstate

  5. Cross-Page Posting (Example) • Get a reference to a control on another page and print the text TextBox txt; txt = (TextBox)PreviousPage.FindControl( "txtPreserve"); Response.Write(txt.Text); http://msdn.microsoft.com/en-us/library/486wc64h

  6. Detecting Cross-Page Postbasks (1) • Test the PreviousPage property to see if it is null • If it is, the page was not loaded as a cross-page postback • Test the IsCrossPagePostBack property of the ‘posting’ page

  7. Detecting Cross-Page Postbacks (2) • The @PreviousPageType directive allows you to use strongly typed syntax if page “b” will only be posted from page “a” • Be careful <%@ PreviousPageTypevirtualPath=“a.aspx” %>

  8. Cross page Postback vs. Server.Transfer • Cross page postbacks are client-based • The Transfer method is server-based • Both allow you to reference the PreviousPage property

More Related