13.07.2015 Views

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

ASP.NET 3.5: A Beginner's Guide - www.mustafaof.com

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

220<strong>ASP</strong>.<strong>NET</strong> <strong>3.5</strong>: A Beginner’s <strong>Guide</strong>validation has separate error messages so that if one is left unfilled, it is the only one thatthrows an error. The following steps show how to create the application:1. Open a new Web Site in Visual Basic 2008, and set the view to Design mode.2. Open the Validation menu in the Toolbox, and drag a RequiredFieldValidator controlonto the Design editor.3. Select the RequiredFieldValidator in the Design window and open the Propertieswindow. Next to the ErrorMessage property, change the default message to“Please enter your name.”4. Add four TextBox controls and using Figure 9-1 as a guide, label and resize them.5. Select the RequiredFieldValidator and in the Properties window selectControlToValidate under the Behavior directory. In the pop-up menu, selectTextBox1. (If you renamed your TextBox controls, select the one that will be used toaccept entered names.)6. Drag a second RequiredFieldValidator control onto the Design editor, and change theError message to “Please select your gender:”.7. Drag a RadioButtonList to the Design window, and place it directly under the validatoryou just placed.8. Select the required field validator, and in the Properties window choosethe ControlToValidate behavior; in the pop-up menu chooseRadioButtonList1.9. Add a Button control and change the Text property value to “Send Information”.10. Double-click the Button to automatically generate an event handler.11. Finally add a Label control at the bottom and remove the Text property. The followingshows the code for the <strong>ASP</strong>.<strong>NET</strong> portion of the application:<strong>ASP</strong>.<strong>NET</strong> ReqFld.aspxdiv{font-family:Verdana;font-size:11pt;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!