tailieunhanh - Building a More Complex Application

Building a More Complex Application In this section, you'll see a more complex Web form that uses Label, TextBox, RadioButtonList, DropDownList | Building a More Complex Application In this section you ll see a more complex Web form that uses Label TextBox RadioButtonList DropDownList and RequiredFieldValidator controls. The form will prompt the user for their name a required field favorite season spring summer fall or winter and gender male or female . The form will also feature a Button control which when pressed will set the Text property of one of the Label controls to a string containing the user s name gender and favorite season. Figure shows how your final form will appear. Figure The appearance of the final form Perform the following steps 1. To create the new project select File New Project in VS .NET. Select Visual C Projects from the Project Types area on the left of the New Project dialog box and select ASP .NET Web Application from the Templates area on the right. Enter http localhost MyWeb-Application2 in the Location field. VS .NET will display a blank form to which you can add controls. 2. Now add the four Label controls listed in Table to your blank form. This table shows the ID and Text property to set for each of your Label controls. Table Label CONTROLS ID PROPERTY Text PROPERTY HelloLabel Hello NameLabel Enter your name SeasonLabel Favorite season Table Label CONTROLS ID PROPERTY Text PROPERTY SexLabel Sex 3. Next add a TextBox control to the right of NameLabel. Set the ID property for your TextBox control to NameTextBox. The user will enter their name in NameTextBox when the form is run. 4. We want the user to have to enter their name if they don t we want to display a message prompting them to do so. To achieve this you use a RequiredFieldValidator control. Add a RequiredFieldValidator control below NameTextBox. Set the ID property for your Required-FieldValidator control to NameRequiredFieldValidator. Set the Text property to You must enter your name Finally set the ControlToValidate property to NameTextBox. 5. Next add a RadioButtonList control to the right .

TÀI LIỆU LIÊN QUAN
10    158    1
6    184    1
7    162    1
5    157    1
6    160    1
6    152    1
6    150    1
6    206    1
7    154    1
5    121    1