在ASP.NET RadioButtonList中将类添加到LI

时间:2011-07-08 14:49:39

标签: c# asp.net class

我有一个RadioButtonList正在呈现为无序列表。我的问题是我正在向ListItem添加一个类,它正在创建一个放置类的span。有没有办法让课程放在LI标签上?我该怎么办呢?

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);

输出如下:

<li>
    <span class="frame-item">
    <input id="INPUTID" type="radio" name="INPUTNAME" value="1">
    <label for="INPUTID">TEXT</label>
    </span>
</li>

1 个答案:

答案 0 :(得分:2)

您可以创建新的css类,如ul.frame-items li { frame-item class definition here },并通过CssClass属性在RadioButtonList上应用frame-items类