Validation Controls
The ASP.NET validation controls are one of the first "gee whiz" features that are introduced to a lot of developers, and rightfully so. These controls take some of the grunt work out of making sure that user input meets certain criteria. If any of these controls finds the input to be invalid, it can display an error message, and the Page object's IsValid property returns false.[View full width]<asp:RequiredFieldValidator id="checkName" runat="server" controlToValidate="NameTextBox"

All of the details required to make this control work are declared right there on the page. You've seen the id and runat attributes in every control, but controlToValidate instructs the control to check on a TextBox control, while the text attribute indicates what the error message to the user should be.These are among the simplest declarative controls in ASP.NET, but they still save us a bit of work. Using them in Visual Studio is even easier, as we can drag and drop them from the toolbox and set the attributes in the property window.