Need to Know More?
Kalani, Amit, et al. ASP.NET 1.0 with C# Namespace Reference . Hoboken, NJ: Wrox, 2002.
Liberty, Jesse and Dan Hurwitz. Programming ASP.NET . Sebastopol, CA: O'Reilly, 2002.
See the ASP.NET Server Controls Overview at http://support.microsoft.com?scid=kb;en-us;Q306459.
Visit the Microsoft Online Seminars on ASP.NET at www.microsoft.com/Seminar/MMCFeed/MMCDisplay.asp?Product=103362.
See The .NET Show: ASP.NET at www.msdn.com/theshow/Episode009.
See the MSDN TV:
Client-Side Script in ASP.NET at
See the MSDN ASP.NET Seminars at www.msdn.com/seminar/mmcfeed/mmcdisplayfeed.asp?Product=103362.
Read MSDN Magazine's "The ASP Column" at www.msdn.com/msdnmag/find/default.aspx?phrase=The ASP Column .
Read about the .NET Framework Regular Expressions at www.msdn.com/library/en-us/cpguide/html/cpconcomregularexpressions.asp.
Chapter 4. Implementing Navigation for the User Interface
Terms you'll need to understand:
Techniques you'll need to master:
This chapter discusses various state management features
provided by ASP.NET, including client-side techniques and
server-side techniques. This chapter also discusses the ASP.NET
intrinsic objects available via the
Round Trip and Postback
A Web application has a distributed execution model. When a
Step 3 is referred to as a page postback , whereas steps 3 and 4 are collectively referred to as a round trip . A round trip involves making a complete trip over the network to the Web server and getting the response back.
The Web applications use Hypertext Transmission Protocol (HTTP)
to establish communication between the Web browser and Web server.
in nature, which means the life
cycle of a Web page is just a single round trip. Between two page
requests, the Web server and the
This model of execution enables a Web server to support a large number of clients because each client request occupies the server resources only for a short duration. However, the disconnected nature of HTTP provides a major challenge to Web developers, who must implement the following functionality in their applications:
ASP.NET provides solutions to these problems built into the programming framework. From the discussion about server controls in Chapter 3, "Controls," you already know that server controls automatically retain their values across page postbacks. You will learn how ASP.NET actually retains the states for server controls later in this chapter in the section titled "State Management." For now, I'll talk about two properties of the Page class IsPostBack and SmartNavigation that provide the other two functionalities from the previous list.
The IsPostBack Property
The IsPostBack property of the Page class returns true when a page is being loaded in response to a client postback. If the page is being requested for the first time, the value of the IsPostBack property is false .
A typical case in which you would use this distinction is when you do not want the server to execute costly initialization operations for each page postback. Instead, the initializations are to be performed only with the first request to the page.
The following example helps you understand round trip and
postback operations and
The previous example uses the event handler for the
event of the
class to check whether the
page is loaded by a postback operation. If that is the case,
executing the code for adding items to the drop-down list is
Also note that the navigation between controls is not smooth. When the form returns after a postback, it does not remember the active control. However, the SmartNavigation property can solve this problem.
The SmartNavigation Property
ASP.NET has a feature called smart navigation that can greatly enhance the user experience of a Web page by
Smart navigation is specified by the SmartNavigation attribute of the Page directive. To enhance the Web form created in the previous example to use the smart navigation feature, you need to modify its Page directive to the following:
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="Example4_1.WebForm1" SmartNavigation="true" %>
Smart navigation is very useful for intranet applications where
you have more control over the browsers used by the users. For such
applications, you might want to
<configuration> <system.web> <pages smartNavigation="true"/> </system.web> </configuration>