CarsSelector Sample: Demonstrates Creating and Using ASP.NET Web Pages
The CarsSelector sample shows you how to build Web Forms page for selecting cars that simulates a simple e-commerce page. The sample demonstrate the following features:
- Data binding: In this sample you use more than one type of data binding:
- Simple data binding.
- Binding to a data table created programmatically (the data source is not coming from a database).
- Using the event handler to dynamically change the binding of some controls.
- Using validation controls.
- Using the Calendar control and validating its entries without using the validation controls.
To build and run this sample, you need a computer running Internet Information Services 5.0 with FrontPage Server Extensions installed.
Building and Running the Sample
To create the solution
- Copy the sample files to your hard disk.
- Create a new Web Application and name it CarsSelector.
- Delete the default Web Forms page by right-clicking the file WebForm1.aspx, and then click Delete on the shortcut menu.
- Add the file CarsSelectorSample.aspx to the project. To do that, right-click the project name, point to Add on the shortcut menu, and click Add Existing Item. Change the Types of files to All Files (*.*), then browse to the file CarsSelectorSample.aspx, select it, and click Open.
- Add the file CarsSelectorSample.aspx.cs to the project. To do that, right-click the project name, point to Add on the shortcut menu, and click Add Existing Item. Then browse to the file CarsSelectorSample.aspx.cs, select it, and click Open. Click OK to overwrite the existing file.
- Set the Web Forms page as a start page. To do that, right-click the file CarsSelectorSample.aspx and click Set As Start Page on the shortcut menu.
For more information on creating Web Forms applications, see Creating and Managing Web Forms.
To build and run the sample
- On the Build menu, click Build Solution.
- On the Debug menu, click Start Without Debugging.
The Web Forms page appears. You can select a car and make choices, and then you see the result bound to a label.
To use the Web form
- Start by selecting a car brand from the drop-down list Brand.
- Choose a model from the Model drop-down list. You will notice that the contents of this list depend on the selected brand of the car.
- Choose the Year, Color, and Mileage from the appropriate drop-down list.
- Enter an e-mail address in the Your Email text box.
- Select one or more check boxes from the Features Desired.
- Select a valid date in the Desired Available Date calendar.
- Click Submit.
Classes and Keywords
This sample demonstrates the following class:
This sample demonstrates the following keywords:
DropDownList, AutoPostback, CheckBoxList, RequiredFieldValidator, RegularExpressionValidator, Dilatable