Performing Cross-Page Posts

By default, if you click a button control, the page containing the control is posted back to itself, and the same page is reloaded. However, you can use the PostBackUrl property to post form data to another page.

For example, the page in Listing 2.20 includes a search form. The Button control in the page posts the form to another page named ButtonSearchResults.aspx. The ButtonSearchResults.aspx page is contained in Listing 2.21.

Listing 2.20. ButtonSearch.aspx

images

Listing 2.21. ButtonSearchResults.aspx

images

In the Page_Load ...

Get ASP.NET 4 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.