Thursday, 29 December 2011

Get checkboxlist text using javascript

In this article we will explore how to get checkbox text in javascript. CheckBoxList text property lays out the text as html lable in the page.

CheckBox Text
Let's see how we can achieve it:

Step 1: Place below html fragment inside form tag of aspx page.



Selected checkbox value:

Step 2: Place below code snippet in page_load to bind data to checkboxlist.

ListItem lst;
string text;
for (int i = 0; i < 10; i++) { text = i.ToString() + " Checkbox in DDL"; lst = new ListItem(text, i.ToString()); chkList.Items.Add(lst); } Step 3: Now place below javascript in the aspx page.


Live Demo
This ends the article of getting text of checkboxlist using javascript.
Like us if you find this post useful. Thanks!

No comments:

Post a Comment