如何向 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/