I have a Asp.net checkBox List cblSubsidiaries.

 <asp:CheckBoxList runat="server" ID="cblSubsidiaries" RepeatColumns="4" />

And I am adding item to it from code behind:

var newListSubItem = new ListItem("ExampleText", "ExampleValue");
newListSubItem .Attributes.Add("class", "cbItems");

This adding of class from code behind add the Span. But I want to add the Class to the <input directly.

This is the output

<span class="cbItems">
<input disabled="" id="contentpage_0_content_0_cblSubsidiaries_4" name="contentpage_0$content_0$cblSubsidiaries$4" value="ExampleText" type="checkbox">
<label for="contentpage_0_content_0_cblSubsidiaries_4">ExampleText</label>

A bit more detail: If I add the attribute e.g. "onclick" then it is directly added to the <input. I want to add another attribute "data-myValue" but it's also added to the Span. I want to use the value of data-myValue in jQuery. But if it is added to span then I cannot use the Value.

Related posts

Recent Viewed