Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Classes to LI in ASP.NET RadioButtonList

Tags:

c#

class

asp.net

I have a RadioButtonList that is being rendered as an Unordered list. My issue is I am adding a class to the ListItem and it is creating a span in which the class is being placed. Is there a way I can have the class placed on the LI tag instead? How can I go about it?

var cblAttributes = new RadioButtonList();
cblAttributes.ID = controlId;
cblAttributes.RepeatLayout = RepeatLayout.UnorderedList;

var pvaValueItem = new ListItem(Server.HtmlEncode(frame.Name), frame.FrameId.ToString());
pvaValueItem.Attributes.Add("class", "frame-item");
cblAttributes.Items.Add(pvaValueItem);

Output is below:

<li>
    <span class="frame-item">
    <input id="INPUTID" type="radio" name="INPUTNAME" value="1">
    <label for="INPUTID">TEXT</label>
    </span>
</li>
like image 863
brenjt Avatar asked Jul 08 '11 14:07

brenjt


1 Answers

You can create new css class like ul.frame-items li { frame-item class definition here } and apply frame-items class on the RadioButtonList via the CssClass property

like image 73
Yuriy Rozhovetskiy Avatar answered Nov 14 '22 23:11

Yuriy Rozhovetskiy