The Page Class and Master Pages


In this chapter, you have seen a range of features of the Page class that implements the ASP.NET Web Forms page. You first examined the basic objects that form the basis for HTTP communication and Web server operation: the HttpRequest, HttpResponse, and HttpServerUtility classes. Each has a series of properties and methods appropriate to its position in the Web page request cycle; for example, HttpRequest provides details of the values submitted by the client, while HttpResponse allows you to access and interact with the response sent back to the client. The HttpServerUtility class provides methods that control page execution and makes tasks such as translating URL-encoded and HTML-encoded strings easier.

The HttpRequest, HttpResponse, and HttpServerUtility classes are all available from the current context, implemented by the HttpContext class that also provides features to assist you in creating Web pages and applicationsan example being the ability to generate trace information for debugging and optimizing your code.

Like the Page class, all these objects are available to your code within the current context. The Page class itself, however, is the most complex of the classes you have seen in this chapter. With dozens of properties, methods, and events available, it provides many features that you will find useful in your ASP.NET pages. This chapter looks at many of these features, including accessing the intrinsic objects such as Application and Session, working with viewstate, finding controls on a page, writing trace information, and using the page-level events.

The chapter then briefly considered how you can subclass the Page class to add custom properties, pre-set existing properties, and use events to initialize features you want to be set on every page.

Finally, you saw how you can make creating and managing the appearance and layout of your site much easier using Master Pages. You also saw how you can use nested Master Pages, device-specific Master Pages, and set the Master Page dynamically at runtime. Finally, you examined techniques for accessing values and controls in the Master Page from a Content Page.

In the next chapter, you will look in more detail at the features of ASP.NET connected with navigation, site menus, and other features related to linking the pages within your Web sites.

 Python   SQL   Java   php   Perl 
 game development   web development   internet   *nix   graphics   hardware 
 telecommunications   C++ 
 Flash   Active Directory   Windows