Creating Custom Controls with User Controls

A Web User control enables you to build a new control from existing controls. By taking advantage of User controls, you can easily extend the ASP.NET Framework with your own custom controls. Imagine, for example, that you need to display the same address form in multiple pages in a web application. The address form consists of several TextBox and Validation controls for entering address information. If you want to avoid declaring all the TextBox and Validation controls in multiple pages, you can wrap these controls inside a Web User control.

Designing Websites with Themes

An ASP.NET Theme enables you to apply a consistent style to the pages in your website. You can use a Theme to control the appearance of both the HTML elements and ASP.NET controls that appear in a page. Themes are different than Master Pages. A Master Page enables you to share content across multiple pages in a website. A Theme, on the other hand, enables you to control the appearance of the content.

Designing Websites with Master Pages

A Master Page enables you to share the same content among multiple content pages in a website. You can use a Master Page to create a common page layout. For example, if you want all the pages in your website to share a threecolumn layout, you can create the layout once in a Master Page and apply the layout to multiple content pages.

You also can use Master Pages to display common content in multiple pages. For example, if you want to display a standard header and footer in each page in your website, then you can create the standard header and footer in a Master Page. By taking advantage of Master Pages, you can make your website easier to maintain, extend, and modify. If you need to add a new page to your website that looks just like the other pages in your website, then you simply need to apply the same Master Page to the new content page. If you decide to completely modify the design of your website, you do not need to change every content page. You can modify just a single Master Page to dramatically change the appearance of all the pages in your application.

Using the Rich Controls

In previous chapters, we examined the ASP.NET controls that you will use in just about any application. In this chapter, we examine a more specialized set of controls known collectively as the rich controls. In the first section, you learn how to accept file uploads at your website. For example, you learn how to enable users to upload images, Microsoft Word documents, or Microsoft Excel spreadsheets.

Next, you learn how to work with the Calendar control. You can use the Calendar control as a date picker. You can also use the Calendar control to display upcoming events (such as a meeting schedule). In this chapter, we also discuss the AdRotator control. This control enables you to display banner advertisements randomly on your website. The control enables you to store a list of advertisements in an XML file or a database table.

Using the Validation Controls

In this chapter, you learn how to validate form fields when a form is submitted to the web server. You can use the validation controls to prevent users from submitting the wrong type of data into a database table. For example, you can use validation controls to prevent a user from submitting the value “Apple” for a birth date field.

In the first part of this chapter, you are provided with an overview of the standard validation controls included in the ASP.NET 3.5 Framework. You learn how to control how validation errors are displayed, how to highlight validation error messages, and how to use validation groups. You are provided with sample code for using each of the standard validation controls.

Using the Standard Controls

In this chapter, you learn how to use the core controls contained in the ASP.NET 3.5 Framework. These are controls that you’ll use in just about any ASP.NET application that you build. You learn how to display information to users by using the Label and Literal controls. You learn how to accept user input with the TextBox, CheckBox, and RadioButton controls. You also learn how to submit forms with the button controls.

At the end of this chapter, you learn how to group form fields with the Panel control. Finally, you learn how to link from one page to another with the HyperLink control.

Overview of the ASP.NET Framework

Overview of the ASP.NET Framework
Let’s start by building a simple ASP.NET page.
For information on installing ASP.NET, see the last section of this chapter. If you are using Visual Web Developer or Visual Studio, you first need to create a new website. Start Visual Web Developer and select the menu option File, New Web Site. The New Web Site dialog box appears (see Figure 1.1). Enter the folder where you want your new website to be created in the Location field and click the OK button.

After you create a new website, you can add an ASP.NET page to it. Select the menu option Web Site, Add New Item. Select Web Form and enter the value FirstPage.aspx in the Name field. Make sure that both the Place Code in

Introduction

Introduction
ASP.NET is Microsoft’s flagship technology for building highly interactive, highly scalable websites. Some of the largest websites hosted on the Internet were built with the ASP.NET Framework, including Dell (www.Dell.com), MySpace (www.MySpace.com), and Microsoft (www.Microsoft.com). If you need to build a highly interactive website that can scale to handle thousands of simultaneous users, then ASP.NET is the technology to use.

ASP.NET 3.5 Tutorials

                                                                 Contents at a Glance


Part I  Building ASP.NET Pages
2         Using the Standard Controls
4         Using the Rich Controls

Part II Designing ASP.NET Websites

Part III Performing Data Access
8         Overview of Data Access
10       Using List Controls

Part IV  Building Components
15         Building Components

Part V  Site Navigation
20         Using Site Maps
21         Advanced Navigation

Part VI  Security
22          Using the Login Controls
23          Using ASP.NET Membership

Part VII  Building ASP.NET Applications
24          Maintaining Application State
25          Caching Application Pages and Data
26          Localizing Applications for Multiple Languages
27          Working with the HTTP Runtime
28          Configuring Applications

Part VIII Custom Control Building
29           Building Custom Control
30           Building Templated Databound Controls

Part IX   ASP.NET AJAX
31           Using Server-Side ASP.NET AJAX
32           Using the ASP.NET AJAX Control Toolkit
33           Using Client-Side ASP.NET AJAX

Part X  Sample Application
34         Building a Code Sample Website