I am using lightbox to show images in enlarge on same page. i have defined in data list view a href tag to get image link and when the user click will get enlarge thumbinal. can anyone tell me how to give href value ? my code is here.
<asp:DataList ID="DataList1" runat="server" DataKeyField="ImageID"
DataSourceID="SqlDataSource1" RepeatColumns="3">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# Eval("ImageURL","~/Images/{0}") %>' BorderColor="#009900"
BorderStyle="Groove" BorderWidth="5px" Height="300px" Width="300px" />
<a href='<%# Eval("ImageURL","~/Images/{0}") %>' rel="lightbox" title='<%# Eval("ImageURL","~/Images/{0}") %>'><asp:DataList ID="DataList1" runat="server" DataKeyField="ImageID"
DataSourceID="SqlDataSource1" RepeatColumns="3">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl='<%# Eval("ImageURL","~/Images/{0}") %>' BorderColor="#009900"
BorderStyle="Groove" BorderWidth="5px" Height="300px" Width="300px" />
<a href='<%# Eval("ImageURL","~/Images/{0}") %>' rel="lightbox" title='<%# Eval("ImageURL","~/Images/{0}") %>'><img src='<%# Eval("ImageURL","~/Images/{0}") %>' />"</a>
<br />
ImageID:
<asp:Label ID="ImageIDLabel" runat="server" Text='<%# Eval("ImageID") %>' />
<br />
UploadedBy:
<asp:Label ID="UploadedByLabel" runat="server" Text='<%# Eval("UploadedBy") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList></a>
<br />
ImageID:
<asp:Label ID="ImageIDLabel" runat="server" Text='<%# Eval("ImageID") %>' />
<br />
UploadedBy:
<asp:Label ID="UploadedByLabel" runat="server" Text='<%# Eval("UploadedBy") %>' />
<br />
<br />
</ItemTemplate>
</asp:DataList>
Advance thanks!
for a path starting with "~" to resolve I'm pretty sure you have add runat="server" to the control so that it's processed by .NET as a .NET control. Otherwise the HREF path will just have "~/images/{0}" which is meaningless in html .. so
<a href='<%# Eval("ImageURL","~/Images/{0}") %>' rel="lightbox" title='<%# Eval("ImageURL","~/Images/{0}") %>'>
becomes
<a href='<%# Eval("ImageURL","~/Images/{0}") %>' rel="lightbox" title='<%# Eval("ImageURL","~/Images/{0}") %>' runat="server">
which should make your href path resolve properly
same with the image
<img src='<%# Eval("ImageURL","~/Images/{0}") %>' runat="server" />
Use a asp:hyperlink it has an ImageURL and a NavigateUrl.
See http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.hyperlink.aspx
<asp:HyperLink id="hyperlink1"
ImageUrl="images/pict.jpg"
NavigateUrl="http://www.microsoft.com"
Text="Microsoft Official Site"
Target="_new"
runat="server"/>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.