Home » none » Validating A WebForms Checkbox . . .

Validating A WebForms Checkbox . . .

. . . and other ASP.NET controls that the Validation controls can not be wired to.

The presentation today may be something you already know how to do.  But, this question comes up repeatedly in my work as a .NET coach, which means there are still people who don’t know how to do this.  There are other people who think they know how to do this but are hacking the solution.  I encourage you to watch the video.  My bet is that 80% of you that do will learn something you didn’t already know about the validation controls and how to use them properly.

Here’s the basic problem.  There are controls in the .NET framework that can not be wired to the standard validation controls.  The checkbox control is one example.  You can’t use the RequiredFieldValidator because it has a value.  It’s either true or false.  And you can’t provide a RegularExpressionValidator or one of the others because it is a boolean value.

So, if I want to make sure a check box is checked before the user continues, for example.  And, I want to make sure that the error message shows up in the error summary control like every other error, how do I do that?

Like this Article? Subscribe to get every article sent to your email.

Related Post

  • Sorting the ListView in ASP.NETSorting the ListView in ASP.NET Are you confused about how to implement sorting in the new ListView control in ASP.NET 3.5?  Join me as I show you in this step by step video showing you exactly how to sort a ListView, […]
  • ListView and the DataPagerListView and the DataPager One of the new controls that Visual Studio 2008 brings us is the ListView.  Now, the ListView control is really several different controls all rolled into one.  There is a lot to see with […]
  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it […]
  • Multi-TargetingMulti-Targeting One of the big new features that have been advertised with Visual Studio 2008 is this thing called Multi-Targeting.  This lets you write code for .NET 2.0 (or 3.0) even though 2008 is […]
  • Add/Edit/Delete with ListViewAdd/Edit/Delete with ListView Last week we took a short look at the new ListView control in ASP.NET 3.5.  Today, we'll take a brief look at Add/Edit/Delete.  This is actually pretty simple stuff.

About Dave Bush

Dave Bush is a Full Stack ASP.NET developer. His commitment to quality through test driven development, vast knowledge of C#, HTML, CSS and JavaScript as well as his ability to mentor younger programmers and his passion for Agile/Scrum as defined by the Agile Manifesto and the Scrum Alliance will certainly be an asset to your organization.

  • http://www.keyplus.co.uk Brian

    Hi Dave,
    I’ve just watched your YouTube video of how to validate a checkbox – it almost worked but I’m a little confused with the code as I use C# in VWD 2008.

    Can you help?


  • Dave

    Probably. Let’s try to do it through the comment system so that others will benefit.

  • Andrew

    Hi Dave, May i get the example validate the checkbox its checked or not? Please



  • Viney Dhiman

    WebForms UnobtrusiveValidationMode requires a
    ScriptResourceMapping for ‘jquery’. Please add a ScriptResourceMapping
    named jquery(case-sensitive).
    this error occur what shou i do ?