Export (0) Print
Expand All

CarsSelector Sample: Demonstrates Creating and Using ASP.NET Web Pages

Visual Studio .NET 2003

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.

Requirements

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

  1. Copy the sample files to your hard disk.
  2. Create a new Web Application and name it CarsSelector.
  3. Delete the default Web Forms page by right-clicking the file WebForm1.aspx, and then click Delete on the shortcut menu.
  4. 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.
  5. 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.
  6. 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

  1. On the Build menu, click Build Solution.
  2. 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

  1. Start by selecting a car brand from the drop-down list Brand.
  2. 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.
  3. Choose the Year, Color, and Mileage from the appropriate drop-down list.
  4. Enter an e-mail address in the Your Email text box.
  5. Select one or more check boxes from the Features Desired.
  6. Select a valid date in the Desired Available Date calendar.
  7. Click Submit.

Classes and Keywords

This sample demonstrates the following class:

System.Web.UI.Page

This sample demonstrates the following keywords:

DropDownList, AutoPostback, CheckBoxList, RequiredFieldValidator, RegularExpressionValidator, Dilatable

See Also

Visual C# Samples | General Samples

Show:
© 2014 Microsoft