Scott Waletzko has been an Information Technology professional and Windows / Web programmer since 1995, with experience in software development and architecture, network design and administration, and project and team management. Currently he is the the Senior Vice President of Technology at Intellisponse, as well as the President of Skystone Software / Echosoft Design Studios, LLC.
At Intellisponse, Scott is responsible for architecture and implementation of the company flagship software called Synapse, the first full-featured Web survey authoring tool for market research, enabling researchers to design, publish, and manage full-featured and logically complex questionnaires to the Internet without programmer interaction.
As president of Skystone Software / Echosoft Design Studios, LLC, Scott is developing a unique Web site content management system named Tempest, which will drive myBard.com and provide comprehensive Web site hosting and content management to anyone with a Web browser.
View all articles by Scott Waletzko...
The following excerpt is from Chapter Two of the book, dealing with validation controls:
"The easiest way to add a validation control to a web form is to drag it from the Toolbox. In this example, four validators have been added to the form: two required field validators and two range validators. In this case, the controls have been added below the table so ASP.NET will use flow layout to position the controls. However, these controls could have been added to a third column of the table. Although these controls aren’t displayed when the form is displayed, the messages in their ErrorMessage properties are displayed if errors are detected.
In this case, the first required field validator checks to make sure that a value has been added to the text box for the interest rate, and the first range validator checks to make sure that this value ranges from 1 to 20. Similarly, the second required field validator checks to make sure that a value has been entered in the text box for years, and the second range validator checks to make sure that this value ranges from 1 to 45.
Validation tests are typically done on the client before the page is posted to the server. That way, a round trip to the server isn’t required to display error messages if any invalid data is detected. In most cases, client-side validation is done when the focus leaves an input control that has validators associated with it. That can happen when the user presses the Tab key to move to the next control or clicks another control to move the focus to that control. Validation is also done when the user clicks on a button that has its CausesValidation property set to True.
To perform client-side validation, a browser must support Dynamic HTML, or DHTML. Because most browsers in use today support DHTML, validation can usually be done on the client. However, validation is always done on the server too when a page is submitted. ASP.NET does this validation after it initializes the page.
When ASP.NET performs the validation tests on the server, it sets the IsValid property of each validator to indicate if the test was successful. In addition, after all the validators are tested, it sets the IsValid property of the page to indicate if all the input data is valid. You can test this property in the event handler for the event that causes the page to be posted to the server. You’ll see how this works when you review the code-behind file for this form."