c# - 在 ASP.NET RadioButtonList 中向 LI 添加类

标签 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>

最佳答案

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

关于c# - 在 ASP.NET RadioButtonList 中向 LI 添加类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6626211/

相关文章:

ASP.NET 统计访问者,而不是机器人

c# - 无法找到请求的.Net Framework 数据提供程序。可能没有安装。(informix)

C++:如何为多维 vector 创建构造函数?

c++ - 在这里运行时出现奇怪的错误

c++ - 作为非成员的算术复合运算符重载

c# - 无法动态地向页面添加控件

c# - 将简单的 Left Outer Join 和 group by SQL 语句转换为 Linq

c# - 使用 Serilog 的模式(通过 ILogger 与使用静态 Serilog.Log)

c# - 即使 DebugType=full,也无法在 Release模式下调试应用程序

c# - 当发送者在队列中发送消息时,RabbitMQ Consumer.Received 事件不会在 asp.net Web 应用程序(作为监听器)中触发