在asp.net中单击时图像不会放大

时间:2013-04-19 07:50:40

标签: asp.net image

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

这是我的代码

    <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());
      }

任何人都可以帮忙吗?感谢。

1 个答案:

答案 0 :(得分:0)

问题出在JavaScript中。我改成了:

<script type="text/javascript">

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

    document.getElementById("ctl00_ContentPlaceHolder1_imgenlarge").src = (str);