CheckBox Enable/Disable Button Control

Some super handy validation controls put together by Scot Mitchell fill the validation void in ASP.NET Web Forms for checkbox & checkbox list controls.

However he expanded on these controls to allow for easy enable/disable functionality for a button triggered by a checkbox. This sort of functionality is quite common with systems that require you to accept the terms and conditions before proceeding, to prevent you from proceeding the button to do so is disabled until you tick the box.

Set up a webpage with a standard checkbox and button control.

<asp:CheckBox Checked=”false” CssClass=”information_control” ID=”termsAndConditionsCB” Text=”I agree to the terms and conditions.” runat=”server” />

<asp:Button ID=”proceedNow” runat=”server” Text=”Proceed” onclick=”proceedNow_Click” CssClass=”proceed_button” Enabled=”false” />

Now, download the demo app Scott put together and place the skmValidators.dll in the root of the .rar file to you documents. I keep all extension .ddl files like this in libs folder in my documents (DocumentsVisual Studio 2010Libs).

Add the custom controls to your toolbox in Visual Studio and drop the CheckBoxValidator onto your page and fill out the info like this:

<asp:checkboxvalidator ID=”CheckBoxValidator1” runat=”server” ControlToValidate=”termsAndConditionsCB” Display=”None” AssociatedButtonControlId=”quoteMeNow” MustBeChecked=”true” />

That was it, if my termsAndConditionsCB was not ticked my proceedNow button was disabled.



Published by

Alan Feekery

Developer, Gamer, Musician, Cyclist and big Motorsport fan... enjoys the odd cup of coffee :)

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s