Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 单击显示当前图像放大_Javascript_Asp.net_Css_Lightbox - Fatal编程技术网

Javascript 单击显示当前图像放大

Javascript 单击显示当前图像放大,javascript,asp.net,css,lightbox,Javascript,Asp.net,Css,Lightbox,这是我的密码 <asp:DataList ID="DataList2" runat="server" BackColor="Gray" BorderColor="#666666" BorderStyle="None" BorderWidth="2px" CellPadding="3" CellSpacing="2" Re

这是我的密码

<asp:DataList ID="DataList2" runat="server" BackColor="Gray" BorderColor="#666666"
                                BorderStyle="None" BorderWidth="2px" CellPadding="3"                      
                                CellSpacing="2" RepeatLayout="Flow" Font-Names="Verdana"
                                Font-Size="Small" GridLines="Both" RepeatColumns="3"  
                                RepeatDirection="Horizontal"
                                Width="100%">

<FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
<HeaderStyle BackColor="#333333" Font-Bold="True" Font-Size="Large" ForeColor="White"
                                 HorizontalAlign="Center" VerticalAlign="Middle" />
    <HeaderTemplate> Employee Details </HeaderTemplate>
    <ItemStyle BackColor="White" ForeColor="Black" BorderWidth="2px" />
    <ItemTemplate>
      <%--imp---*********---------********--%>    
      <a data-lightbox="roadtrip" href='<%# Eval("Path", "~/PlayerImages/{0}") %>' > 
         <asp:Image ID="Image1" runat="server" ImageUrl='<%# Bind("Path",
                   "~/PlayerImages/{0}") %>' Width="50%" Height="50%" />
      <%--imp---*********---------********--%>
      </a><br />
      <b>Employee Name:</b>
      <asp:Label ID="lblCName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>

      </ItemTemplate>
</asp:DataList>  

员工姓名:
我标记为imp的代码区域
在第一行中,我设置了
href=''
,因为我想显示当前图像的放大图像,但它不起作用。
原因是我认为数据没有绑定到该
href
,因为当我通过一个固定路径代替
Eval
时,它会向我显示该图像。
我不知道怎么做。
请给我建议解决方案。

更改
DataList
定义如下

<asp:DataList ID="DataList2" runat="server" BackColor="Gray" BorderColor="#666666"
                            BorderStyle="None" BorderWidth="2px" CellPadding="3"                      
                            CellSpacing="2" RepeatLayout="Flow" Font-Names="Verdana"
                            Font-Size="Small" GridLines="Both" RepeatColumns="3"  
                            RepeatDirection="Horizontal"
                            Width="100%" ItemDataBound="DataList2_ItemDataBound">
<ItemTemplate>
<asp:Literal runat="server" ID="ltrlLightBox"/>
  <b>Employee Name:</b>
  <asp:Label ID="lblCName" runat="server" Text='<%# Bind("Name") %>'></asp:Label>
  </ItemTemplate>
访问
ItemDatabound事件中的
literal控件

protected void DataList2_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Literal ltrlLightBox = (Literal)e.Item.FindControl("ltrlLightBox");
        DataRow drow = (DataRow)e.Item.DataItem;
        ltrlLightBox.Text = "<a data-lightbox=\"roadtrip\" href=\"PlayerImages/" + drow["Path"].ToString() + "\" > <img src=\"PlayerImages/" + drow["Path"].ToString() + "\" width=\"50%\" height=\"50%\" /></a><br />";
    }
}
protectedvoid DataList2\u ItemDataBound(对象发送方,DataListItemEventArgs e)
{
如果(e.Item.ItemType==ListItemType.Item | | e.Item.ItemType==ListItemType.AlternatingItem)
{
Literal ltrlLightBox=(Literal)e.Item.FindControl(“ltrlLightBox”);
DataRow drow=(DataRow)e.Item.DataItem;
ltrlLightBox.Text=“
”; } }
您可以使用
literal
控件并在
ItemDatabound
事件中形成html,然后用此html替换文本。请给出一个示例,说明您绑定到数据列表的数据源是什么?我正在将图像路径和名称绑定到列表耶,这就是我要问的,就像是DataTable或dataview什么的?你的代码可以工作,但我在你的答案中做了一些修改,谢谢