3

にハイパーリンクを追加するにはどうすればよい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>" />

アップデート

他のコードがこれを台無しにしていました。したがって、元のコードに問題はありませんでした。で rdlTest をクリアしてリロードする機能がPage_Loadありrdl.Items.Add(new ListItem("1","A")、それが作業中のマークアップをオーバーライドしています。

4

2 に答える 2

1

あなたはちょうどのようなことをすることはできません...

<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 は同様に機能するはずです。

于 2012-09-19T20:11:21.490 に答える
0

いつでもIDを割り当ててから、Javascript(またはjQuery)でonclickイベントを接続できます。

<asp:ListItem Value="1" Text="A" ID = "A"></asp:ListItem>

$('#A').click(function(){

window.location='Page2.aspx?1'

}
于 2012-09-19T20:12:42.190 に答える