AJAX Control Toolkit - RequiredFieldValidator Extender

7. March 2008

I just released the first version of the ASP.NET RequiredFieldValidator Extender control. The control is built on top of Microsoft's AJAX Control Toolkit. What is does is extend the behavior of an ASP.NET RequiredFieldValidator control to apply a CSS class to the control being validated if it is invalid (client side). It also will apply a CSS class to an ASP.NET Label control as well. For example, say you have a textbox on your ASP.NET page that is required such a name textbox:

If the user submits the form with an empty textbox, the result will be that the textbox and label will have the CSS class you specify applied to them. In my case, I wanted them to show in red:

And here is a screenshot of the ASP.NET Markup used to create the sample above:

With this control, all you need to do to add your custom CSS to a required field is to reference the assembly in your ASP.NET project, register the control in your web.config file,  and then add the RequiredFieldExtender as shown above to your ASP.NET Markup.  The control can be used against any control being validated with a RequiredFieldValidator control such as TextBox, RadioButtonList, DropDownList, etc.  I think this control will be huge time saver for ASP.NET developers who need to do client-side control validation with CSS classes.

Complete source code, assembly, and sample ASP.NET web app are available here  (Releases tab) at the control's project on CodePlex.com. I should note the Solution was built in Visual Studio 2008 against the .NET Framework 3.5.

Questions? Drop me a comment and I will try to answer. Laughing 

web development

Comments

Comments are closed