c# - 将超链接添加到 RadioButtonList

标签 c# asp.net webforms

如何向 RadioButtonList 添加超链接?

我尝试了以下方法,但它仍然呈现为纯文本。

<asp:RadioButtonList runat="server" id="rdlTest">
    <asp:ListItem Value="1" Text="<a href='Page2.aspx?1'>A</a>"></asp:ListItem>
    <asp:ListItem Value="2" Text="<a href='Page2.aspx?2'>B</a>"></asp:ListItem>
</asp:RadioButtonList>

我知道以下工作,但我想使用 RadioButtonList 而不是 RadioButton

<asp:RadioButton runat="server" ID="rdoTest" Text="<a href='Page2.aspx?1'>A</a>" />

更新

一些其他代码搞砸了。所以我的原始代码没有问题。 我有一个函数可以使用 rdl.Items.Add(new ListItem("1","A")Page_Load 清除和重新加载 rdlTest,这会覆盖工作标记。

最佳答案

你就不能做一些像...

<asp:CheckBoxList ID="chk" runat="server">

        <asp:ListItem Value="0"><a href="http://www.asp.net">asp.net</a></asp:ListItem>

        <asp:ListItem Value="1"><a href="http://forums.asp.net">forums.asp.net</a></asp:ListItem>

</asp:CheckBoxList>

RadioButtonList 和 CheckBoxList 的工作方式应该相似。

关于c# - 将超链接添加到 RadioButtonList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12502098/

相关文章:

c# - 如何使用 FakeItEasy 验证 FindOneAndUpdateAsync 方法针对伪造的 MongoCollection 运行?

c# - 有选择地阻止调试器在第一次出现异常时停止

在子文件夹中运行 MVC 的 Asp.net WebForms 应用程序

c# - 夹紧角度时相机开始崩溃

c# - 如何将 XNode 转换为自定义类型?

javascript - 如何停止按钮上的页面重新加载单击jquery

javascript - 如何居中对齐 Asp.net 网站中的实际文本框

ios - PasswordSignInAsync 在本地工作但不在 Azure 中工作

javascript - 如何使用 jquery 隐藏/显示 <panel>?

c# - 从复选框列表中删除所选内容