Supplied Functionality

Specifically, the System.Web interface provides the functionality that enables client/browser communication, which is key for ASP.NET pages.The System.Web.HttpResponse class encapsulates Hypertext Transfer Protocol (HTTP) response information. Likewise, the System.Web.HttpRequest object encapsulates HTTP values sent from a client.

In addition, you now have the HttpServerUtility object, which provides helper methods that parse HTTP information and return server variables.

These objects in ASP.NET are much more powerful, however, than their older counterparts. They are fully object-oriented, which means you can inherit or extend them, and they also provide a multitude of new methods and properties that will be useful for ASP.NET developers.

Note, however, that the Request and Response objects hearken back to the days of the Request/Response model of Internet communication. One of the main benefits of ASP.NET is that it abstracts this older model with an event-driven model, which allows for more intuitive application programming. In general, you'll want to use an event-driven method to interact with data rather than using Request or Response. For example, rather than using the following code snippet to display text to the user:

Response.Write("Hello World!")

You should use something like this:

lblText.Text = "Hello World!"

Where IblText is a label object in the UI.

This namespace also has classes for dealing with many common HTTP related functions: the HttpCookie object lets you create and read cookies; the HttpApplication class provides control over the ASP.NET application itself; HttpCachePolicy is used to set HTTP headers that specify how you can cache ASP.NET pages; and the HttpFileCollection class provides access to files uploaded by clients. There are quite a few other useful classes in this namespace as well— see the .NET Framework SDK Documentation for more information.

System.Web.UI Namespace Set

In the System.Web namespace, the System.Web.UI subnamespace is probably the most used collection of objects in ASP.NET. It provides all the functionality you'll need to create, render, and display user interface (UI) elements to the end user.

The System.Web.UI.Control object is the base class for almost all of the UI objects you'll be using in ASP.NET. It provides methods and properties that are common to all ASP.NET server controls, thus making it easy to learn how each control works. Figure 2.3 shows the hierarchy of objects based on this class.

Figure 2.3 The Hierarchy of UI Objects

System.Web.UI.Control Object

HtmlControls Namespace HtiiiKoiitrol

All objects belong to System.Web.UI namespace.

System.Web.UI Namespace | TemplateControl

LiteralControl

UserControl |

DataBoundLiteralControl

WebControls Namespace

WebControl

0 0

Post a comment