How do I get an ASP RadioButtonList where the buttons don't have any text next to them?
I have a list of radio buttons on my ASP.NET page displayed thus:-
<asp:RadioButtonList id="my_radio_box"
runat="server"
AutoPostBack="True"
RepeatDirection="Horizontal"
onselectedindexchanged="my_function">
<asp:ListItem Value="0"></asp:ListItem>
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
</asp:RadioButtonList>
but I would like the buttons to be displayed without any accompanying text (there'll be other things on the page to make clear what is required). I've tried leaving no space in between the >< in the list item, and also a space and a non-breaking space, but the value text is displayed whenever I do this.
How do I have a radiobutton with no text?
(I've tried setting the foreground开发者_StackOverflow colour the same as the background colour; this works, but doesn't seem right to me.)
MSDN says "If the Text property contains Nothing, the get accessor returns the value of the Value property. If the Value property, in turn, contains Nothing, String.Empty is returned."
So I imagine you could use a whitespace character in the Text
property to 'fool' it?
Have you tried adding a whitespace to the Text
property of the ListItem
?:
<asp:ListItem Value="0" Text=" " />
EDIT
I created a test case using the above, and it works:
<asp:RadioButtonList ID="rd" runat="server">
<asp:ListItem Value="0" Text="" />
<asp:ListItem Value="1" Text="" />
</asp:RadioButtonList>
精彩评论