Click here to Skip to main content
Click here to Skip to main content

How to make text of an html checkbox clickable (like ASP.NET control)

By , 29 Jun 2011
Rate this:
Please Sign up or sign in to vote.
If you put a label HTML tag after the checkbox (either HTML check box or Server Side checkbox control), and set the ID of the check box to the "for" attribute of the label tag, clicking the text in the label tag will click the checkbox:
The code will be as below:
<input type="checkbox" id="checkbox1"/>                                                             
<label for="checkbox1">
 label text


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Bahram Ettehadieh
Web Developer
Iran (Islamic Republic Of) Iran (Islamic Republic Of)
I hold a BS degree in software engineering and am a Microsoft Certified Solution Developer(MCSD).
I have more than 8 years of experience in .NET developement, mostly web develop using C# and ASP.NET.

Comments and Discussions

GeneralReason for my vote of 1 This is basic, all over the internet... PinmemberKronass3-Jan-12 18:26 
GeneralRe: Reason for my vote of 1This is basic, all over the internet... PinmemberCarsten V2.024-Aug-12 5:50 
GeneralReason for my vote of 4 Good Pinmemberrahulpriyan2-Jan-12 17:29 
GeneralReason for my vote of 5 Very good PinmemberVano Maisuradze12-Aug-11 4:26 
GeneralReason for my vote of 5 interesting PinmemberMember 76920994-Jul-11 22:59 
GeneralReason for my vote of 5 Looks Good PinmemberToniyo Jackson26-Jun-11 23:08 
QuestionThanks for sharing PinmemberAnjum.Rizwi4-Jul-11 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140415.2 | Last Updated 29 Jun 2011
Article Copyright 2011 by Bahram Ettehadieh
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid