O'Reilly logo

Learning ASP.NET 2.0 with AJAX by Dan Hurwitz, Jesse Liberty, Brian MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7: State and Life Cycle

Answers to Quiz Questions

  1. A session is the period of time in which a single user interacts with an application, no matter how many individual pages he or she visits.

  2. The state of a page refers to the current values of all controls on the page, including any changes made by the user.

  3. Add the Trace="True" attribute to the Page directive to see the page Trace, including the stages of the page life cycle, and the control hierarchy.

  4. The postback mode is determined in the Start phase of the life cycle.

  5. The Page_Load event is the most common event to handle if you want to take actions during the Load phase.

  6. ASP.NET manages Control state, View state, Session state, and Application state. You cannot affect the management of the Control state.

  7. The EnableViewState="false" attribute disables view state for more complex controls. Simpler controls, such as text boxes, retain their state no matter what.

  8. Use the state bag to store the value of a counter that increments each time the page is loaded. If you navigate to a separate page, the counter will reset, but not if you click the browser's Refresh button.

  9. Save the user's name in session state.

  10. Use the syntax Session("username") = <user's name>.

Answers to Exercises

Exercise 7-1. The trick to this exercise isn't the code—it's where you put it. You want to evaluate the IsPostBack attribute, and take action based on its value, so the best place to do that is in the Page_Load event. Just a simple bit of code in the Page_ Load ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required