views:

795

answers:

3

In my application I have a RadioButtonList:

<asp:RadioButtonList runat="server" ID="CardTypeRadioButtonList" RepeatDirection="Horizontal">
    <asp:ListItem Value="Visa">
        <img src="../images/icon_visa.gif" alt="Visa" align="absmiddle">&nbsp;Visa
    </asp:ListItem>
    <asp:ListItem Value="MasterCard">
        <img src="../images/icon_mc.gif" alt="MasterCard" align="absmiddle">&nbsp;Mastercard
    </asp:ListItem>
</asp:RadioButtonList>

However, sometimes Visual Studio generates the following code automatically and inserts it into my ListItems:

&lt;img src=&quot;../images/icon_visa.gif&quot; alt=&quot;Visa&quot; align=&quot;absmiddle&quot;&gt;&#160;Visa

Any idea how to make this go away?

A: 

you are missing '<' at the second 'img' tag

<asp:RadioButtonList runat="server" ID="CardTypeRadioButtonList" RepeatDirection="Horizontal">
<asp:ListItem Value="Visa">
    <img src="../images/icon_visa.gif" alt="Visa" align="absmiddle"> Visa
</asp:ListItem>
<asp:ListItem Value="MasterCard">
   <img src="../images/icon_mc.gif" alt="MasterCard" align="absmiddle"> Mastercard
</asp:ListItem>

DaDa
That happened when I copied and pasted the code. It is fixed in the original message - thanks for noticing.
Mike C.
A: 

I tried putting a blank Text attribute on each ListItem. Hopefully this makes this issue go away.

Mike C.
This seems to be the correct answer.
Mike C.
A: 

I had a similar issue with Telerik controls about a year ago and ended up writing a macro to fix it as needed because I couldn't figure it out. That's not the best solution but if you can't figure out what to do its very easy to create a macro to repair the code as needed in Visual Studio.

jarrett
So far my solution of adding a blank Text attribute to the list item object seems to be working. It's had to re-create the problem, but if I go a week or two without it happening again I'll call it good.
Mike C.