1

在我的页面中,我有一个大图像和一组小单元图像。大图像将在页面加载时加载。但是当我单击小图像时,它会放大并代替大图像显示。小图像显示在页面上。但它对点击它们没有影响

这是我的代码

    <div class="invDetailImage">
         <img id="imgenlarge" src="" runat="server" alt="" align="middle" style="max-height:380px; max-width:579px; vertical-align:middle;"/>
          <asp:Label runat="server" ID="lblerr"  Visible="false"  style="max-height:380px; max-width:579px; vertical-align:middle;font-size:large;"></asp:Label>
    </div>
    <!-- SMALL IMAGES -->
    <div class="invDetailPhotoBox" runat="server" id="photobox"> 
       <asp:Label runat="server" ID="lblphotos" Text="Select a photo below to view in the window above:"></asp:Label><br />
       <asp:Repeater runat="server" ID="rptrinventoryphotos"  onitemdatabound="rptrinventoryphotos_ItemDataBound">
            <ItemTemplate>
               <img id="imgInventory" src="" runat="server" alt='<%#Eval("ImagePath")%>' style="display:none;"  />
                 <div onclick="large('<%#Eval("ImagePath")%>')" style="float:left;clear:none; margin-left:-12px;">
                  <asp:Image ID="Image1" Visible="true"  runat="server" />
                 </div>
              </ItemTemplate>
        </asp:Repeater>
   </div>

<script type="text/javascript"> function large(src) { 
var str=src; document.getElementById("ctl00_ContentPlaceHolder1_imgenlarge").src = (str); 
} 

function loading(img) { img.src = "images/loading.gif"; } 
</script>

     protected void rptrinventoryphotos_ItemDataBound(object sender, RepeaterItemEventArgs e)
     {
        HtmlImage img1 =(HtmlImage) e.Item.FindControl("imgInventory");
        Image img = (Image)e.Item.FindControl("Image1");
        img.ImageUrl = "http://localhost:22525/DWLive/ImageResizeHandler.ashx?imgPath=" + img1.Alt + "&width=75&height=56";

        img.Style.Add("margin-left", "-12px");
        img.Style.Add("background-image", "url('images/loading9.gif')");
        img.Style.Add("background-repeat", "no-repeat");
        img.Style.Add("background-position", "center left");
        //img.Attributes.Add("onclick", "large('" + img1.Alt + "')");
        string[] a = img1.Alt.Split((@"/").ToCharArray());
      }

有人可以帮忙吗?谢谢。

4

1 回答 1

0

问题出在 JavaScript 中。我将其更改为:

<script type="text/javascript">

    function large(link) { 
        var str = link;
    }

    document.getElementById("ctl00_ContentPlaceHolder1_imgenlarge").src = (str);
于 2013-04-19T10:06:09.667 回答