Sams Teach Yourself ASP.NET in 21 Days, Second Edition By Chris Payne
Table of Contents
Day 5. Beginning Web Forms
Does maintaining the viewstate slow down performance? Is there any way to turn it off?
Maintaining viewstate decreases performance very slightly, if at all. There's an additional step that ASP.NET must accomplish when maintaining viewstate. In performance-critical situations, you can disable viewstate with the following:
You can set this property for any individual control, or for the page as a whole, in the <%@ Page %> directive.
Some of the actions won't do anything on my Web form. What's wrong?
Don't forget to enclose all the controls for which you want to handle events in an HtmlForm control: <form runat="server">. (This is a common mistake.)
Also, make sure that you're using the correct syntax to declare the event handler:
Finally, remember that events are handled in no particular order on the server. Occasionally, you may create an event handler that effectively stops another event from occurring.
For example, in the Page_Load event, you may clear the text from a TextBox. The method that handles the TextChanged event of the TextBox won't work properly because the Page_Load event has already cleared the text. In this case, check the IsPostBack property to make sure you aren't executing code that you don't need or don't want to execute.