本文介绍了将图片添加到在ASP.Net一个单选按钮列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将图像添加到一个单选按钮列表控件,但它不工作。

I am trying to add an image to a radio button list control but its not working..

这个我试过..

RadioButtonList2.Items.Add(新的ListItem(的String.Format(SRC ='.. /颜色/ 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>

但它说img标签不能被嵌套在列表项的标签。请帮我..

but it says img tag cant be nested with the listitem tag.. Please help me out..

推荐答案

您需要指定调节控制,您要设置的src 标记,但没有图像控制。试试这个: -

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>

这篇关于将图片添加到在ASP.Net一个单选按钮列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 01:04