Google Search

Google
 

Wednesday, June 4, 2008

ASP.NET Validation Controls

ASP.NET validation controls provide an easy-to-use but powerful mechanism of ensuring that data is entered correctly on the forms. There are 6 validation controls included in the ASP.NET 2.0 and ASP.NET 3.5 versions. If you are not familiar with Validation Controls in ASP.NET, here’s a recommended read for you.
Let us see some tips and tricks that can be applied to the validation controls. These tips and tricks are for beginner and intermediate users who have been using validation controls.

Tip 1: Always use Page.IsValid before submitting data. Apart from the other benefits, using it prevents submitting data from old browsers that do not support javascript.

Tip 2: To prevent validation to occur on the click of the Cancel button, set the ‘CausesValidation’ property to false


Tip 3: Use the ‘InitialValue’ property of the RequiredFieldValidator to validate controls like combobox which have a default value.
For eg: If your combobox has a default item called “--Select --“ and you want that the user should select a value other than the default value before submitting the form, then set the ‘InitialValue’ property of the RequiredFieldValidator to
“--Select--“.







Check out more validation control tips and tricks over here
http://www.dotnetcurry.com/ShowArticle.aspx?ID=121

No comments: