Previous Section  < Day Day Up >  Next Section

Chapter 16. ASP.NET Web Forms and Controls

Topics in This Chapter

  • Web Client-Server Communications: Web page requests and responses rely on HTML to represent content, and HTTP to define the protocol that governs client-server interaction. JavaScript, ASP, and ASP.NET are compared as ways to develop an application.

  • Structure of an .aspx Page: An .aspx Web page is compiled as a class. It contains a variety of directives that control the page's behavior and can link it to external code. This section looks at the basic elements that comprise an .aspx file, including how Viewstate is used to maintain state information for the form.

  • Inline and Code-Behind Pages: ASP.NET offers three models for designing a Web application: inline code, code-behind, and code-behind with partial classes. The latter two permit the page interface to be separated from the program logic. The implementation code is placed in a code-behind file that is referenced by an .aspx page.

  • HTML Server-Side Controls and Web Controls: ASP.NET provides controls that correspond to HTML tags and are accessed as classes in the server-side code. It also provides a number of native "Web" controls that include features not found on standard HTML controls. These include validation controls, data source controls, and sophisticated data display controls such as the DataList, GridView, and TReeView.

  • Master and Content Pages: ASP.NET supports the creation of a master Web page that serves as a template for other "content" pages that visually inherit from it. This chapter explains how to create master pages containing special "place holder" controls that define where derived content pages may insert their custom content.

Developing applications to run on the Internet is a broad topic, and this book devotes its last three chapters to the subject. This chapter introduces key features of ASP.NET and focuses on using controls to create Web pages; Chapter 17, "The ASP.NET Application Environment," looks at application development issues such as managing sessions and configuring ASP.NET control files; and the book's final chapter discusses Web Services.

ASP.NET is technically regarded as the next generation of ASP. There are syntactic similarities and compatibilities, but the differences are even greater. Thus, this chapter makes no attempt to explain ASP.NET in terms of ASP. There are some comparisons, but no prior knowledge of ASP is assumed. You will also find traces of JavaScript sprinkled in a couple of applications, but the code is easily understood within the context of the examples.

The first section provides a tour of client-server Web interaction. It begins with a simple JavaScript application that demonstrates the fundamental techniques used to transfer information between a client and Web server. It then shows how the ASP.NET model encapsulates these principles and adds an object-oriented approach to Web page design and implementation. Subsequent sections survey the array of Web presentation and validation controls. Special attention is given to the DataList and GridView controls.

One note: IIS (Microsoft Internet Information Server) is conspicuous by its absence in our discussion. Although all of the applications were tested in an IIS environment, and the preponderance of ASP.NET applications will run on this Web server, they are not bound to it. Microsoft has created an open-source HTTP server named Cassini that is written in C#. It's fully HTTP/1.1 compliant, supports directory browsing, as well as many of the standard MIME types, and most importantly, supports ASP.NET. It has been tested on Apache servers and is clearly geared toward making ASP.NET the Web development tool of choice for multiple Web platforms.

    Previous Section  < Day Day Up >  Next Section