Search code examples
asp.netradiobuttonlist

ASP.NET RadioButtonList: the element 'br' cannot be nested within the element 'listitem'


for example i have this radio button.

(o) item1  (o) item 2

however, i want it to be like:

(o) item1   (o) item2
  line here   line here

My current markup is:

<asp:RadioButtonList ID="RadioButtonList1" runat="server" RepeatDirection="Horizontal" Width="650px" Font-Size="Smaller">
    <asp:ListItem Selected="True" Value="0">Relax<br>(MY MAN)</asp:ListItem>
    <asp:ListItem Value="1">Relax Again<br>(My Man)</asp:ListItem>
    <asp:ListItem Value="2">Relax Again 2<br>(MyMan)</asp:ListItem>
    <asp:ListItem Value="3">Relax 3<br>(My Man)</asp:ListItem>
    <asp:ListItem Value="4">Relax 4<br>(My Man)</asp:ListItem>
    <asp:ListItem Value="5">Relax 5<br>(My Man)</asp:ListItem>
    <asp:ListItem Value="6">Relax 6<br>(My Man)</asp:ListItem>
</asp:RadioButtonList>

But it generates the following validation error messages: the element 'br' cannot be nested within the element 'listitem'.


Solution

  • <asp:radiobuttonlist id="RadioButtonList1" runat="server" repeatdirection="Horizontal" width="650px" font-size="Smaller" xmlns:asp="#unknown">
    <asp:listitem selected="True" value="0" text="Relax <br>(MY MAN)"></asp:listitem>
    <asp:listitem value="1" text="Relax Again<br>(My Man)"></asp:listitem>
    <asp:listitem value="2" text="Relax Again 2<br>(MyMan)"></asp:listitem>
    <asp:listitem value="3" text="Relax 3<br>(My Man)"></asp:listitem>
    <asp:listitem value="4" text="Relax 4<br>(My Man)"></asp:listitem>
    <asp:listitem value="5" text="Relax 5<br>(My Man)"></asp:listitem>
    <asp:listitem value="6" text="Relax 6<br>(My Man)"></asp:listitem>
    

    Got this to work! Woohoo! just add text property thats all.