如何根据ID提供图像动态路径以及如何在html中给出路径?

时间:2014-01-09 10:26:32

标签: c# html asp.net

我有转发器,并且在其事件中,bind_itemda在女巫中我得到的形象如下:

string hotelid = ((Label)e.Item.FindControl("lblhotelid")).Text.ToString();

        dr = d.FetchDataReader("SELECT   HotelName,CityId,SrNo,StateId,shortdescription FROM HotelMaster  WHERE srno ='" + hotelid + "'");

        if (dr.Read())
        {

            string stateid, cityid;
            stateid = dr["stateid"].ToString();
            cityid = dr["Cityid"].ToString();

            Image img = (Image)e.Item.FindControl("imghotel");

            img.ImageUrl = "http://bindassholidays.info/Photos/HotelPhotos" + "/" + stateid + "/" + cityid + "/" + hotelid + "/" + hotelid + ".jpg";

        }
        dr.Dispose();
        dr.Close();

现在我想在html中使用此路径,但它无效。

我想通过提供此路径来弹出图像,如何在后面的代码中使用它(代替#)

<asp:repeater ID="rephotelbind" runat="server" onitemdatabound="rephotelbind_ItemDataBound"> 
<ItemTemplate>
 <div class="related_project">
                                            <div class="overlay_a related_img">
                                                <div class="overlay_wrapper">
                                                <asp:Image ID="imghotel" runat="server" Height="175" Width="175"></asp:Image>

                                                    <div class="overlay">
                                                        <a class="overlay_img" href="#" rel="lightbox" title=""></a>
                                                        <a class="overlay_project" href=""></a>

                                                    </div>
                                                </div>
                                            </div>
                                            <h4><a href='<%# "hotelview_more.aspx?hid="+Mainclass.Encrypt(Eval("SrNo").ToString()) %>'> <asp:Label Visible ="false" ID="lblhotelid" runat="server" Text='<%#Eval("SrNo") %>'></asp:Label>
                                            <asp:Label ID="lblhotelname" runat="server" Text='<%# Eval("hotelname")%>'></asp:Label></a></h4>
                                            <p><asp:Label ID="lblhotelinfo" runat="server" CssClass="ShortDesc" Text='<%#Eval("shortdescription") %>' height="60px" width="185px" Style="word-break: break-all; word-wrap: break-word;"> </asp:Label>

                                            ,<a href='<%# "hotelview_more.aspx?hid="+Mainclass.Encrypt(Eval("SrNo").ToString()) %>'> [...]</a>


                                        </div>

 </ItemTemplate>
 </asp:repeater>

0 个答案:

没有答案