Forms Should Post Back to the Same Page


To take full advantage of the ASP.NET framework, you should not create HTML forms that post to a separate page. If a form posts to another page, any view state maintained by the page is lost.

In ASP Classic, it is very common to have a form that posts data to a second page, as illustrated in Figure A.1.

Figure A.1. Posting to a new page.

graphics/ap01fig01.jpg

The preferred method for working with forms in the ASP.NET framework is to post forms back to the same page. Posting a form back to itself is called a postback . Performing a postback is illustrated in Figure A.2.

Figure A.2. Performing a postback.

graphics/ap01fig02.jpg

When you have a form post back to itself, you can take advantage of view state (property values of controls are automatically preserved between posts). After you perform a postback, you can use the Response.Redirect method to send a user to a new page.



ASP.NET Unleashed
ASP.NET 4 Unleashed
ISBN: 0672331128
EAN: 2147483647
Year: 2003
Pages: 263

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net