简体   繁体   中英

Add Classes to LI in ASP.NET RadioButtonList

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM