Adding image to a radio button list in ASP.Net
asp.net, c#, radiobuttonlist
Solution
You need to specify the control control, you are trying to set the `src` tag but there is no image control. Try this:-
RadioButtonList2.Items.Add(new ListItem("<img src='"+"../Colors/Dallas_#625527_1.1.png"+"'/>"));
You can also add this at design time, like this:-
<asp:RadioButtonList ID="imagetest" runat="server">
<asp:ListItem Text='<img src="Image1.jpg" alt="img1" />' Value="1" Selected="True" />
<asp:ListItem Text='<img src="Image2.jpg" alt="img2" />' Value="2"></asp:ListItem>
</asp:RadioButtonList>
Problem
I am trying to add an image to a radio button list control but its not working.. I tried this.. RadioButtonList2.Items.Add(new ListItem(String.Format("src='../Colors/Dallas_#625527_1.1.png'>"))); but the whole image tag appears as text I tried I design time as well ``` <asp:RadioButtonList ID="rbListImages" runat="server"> <asp:ListItem Text="One" Value="1"><img src="../Colors/Dallas_#625527_1.1.png" alt="" /></asp:ListItem> </asp:RadioButtonList> ``` but it says img tag cant be nested with the listitem tag.. Please help me out..