如何使用data-src在div标签中显示数据

时间:2014-08-06 07:45:02

标签: c# html asp.net entity-framework

用于显示图片的代码。

HTML:

 <asp:Repeater ID="Rep_slider" runat="server">
    <ItemTemplate>
        <div data-src='<%#("~/PicUpload/") + Eval("pic")%> '  runat="server">
            <div class="camera_caption moveFromLeft camera_text_center">
                <div class="caption_slider h2">
                </div>
            </div>
        </div>
    </ItemTemplate>
 </asp:Repeater>

用于从DB中选择的代码:

 var slideshow = from anything in obj.sliders
                    select anything;
    Rep_slider.DataSource = slideshow.ToArray();
    Rep_slider.DataBind();

1 个答案:

答案 0 :(得分:3)

我认为你想要显示div与背景图像。尝试使用style="background-image:url('<%#("~/PicUpload/") + Eval("pic")%>')"代替data-src