65.9K
CodeProject is changing. Read more.
Home

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

starIconstarIconstarIconstarIcon
emptyStarIcon
starIcon

4.88/5 (15 votes)

Jun 27, 2011

CPOL
viewsIcon

55538

Make text of an html checkbox clickable (like ASP.NET control)

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
</label>