显示加载图像进度,直到在ASP.Net webform中下载实际图像

时间:2012-04-22 07:38:18

标签: jquery css webforms

我正在开发一项功能,我可以使用动画图像显示加载进度,直到下载实际图像。

我有一个页面有很多图像我循环记录并使用转发器控件显示它们。下面是代码HTML-CSS

的示例
<asp:Repeater ID="rpt4x42" runat="server" EnableViewState="False">
    <ItemTemplate>
         <asp:HyperLink ID="hylTopFour2" style=" text-decoration:none;" runat="server" 
                                   NavigateUrl='<%# getURL(Eval("ArticleID")) %>' BorderWidth="0px" meta:resourcekey="hylTopFour2Resource1">
          <div id="articleContainer2" class="articleContainer" >
               <div id="ArticleImgHP-container" >
                    <asp:Image ID="imgTopFourImg2" runat="server" width="170px" height="112px" CssClass="ArticleImgHP"
                                                    border="0" ImageUrl='<%# getImagePath(Eval("ArticleThumNailImage")) %>'  />
               </div>
               <div class="Details4x4">
               <div  class="Title4x4" >
                     <asp:Label ID="lblTopFourTitle" runat="server" Text='<%# getTitle(Eval("ArticleTitle")) %>'></asp:Label>
                </div>
                <div class="hLine4x4"></div>
                <div class="dateWrapper4x4">
                <div class="Date4x4">
                     <asp:Label ID="lblTopFourDate" runat="server"  
                                                               Text='<%# FormatDate(Eval("[ArticlePublishDate]")) %>'></asp:Label>
                </div>
               </div>

             </div>

           </div>
</asp:HyperLink>
                             </ItemTemplate>
                        </asp:Repeater>

                </div>  

CSS

   img.ArticleImgHP {
         /* Set the width and height to the size of its container */
        width : 100%;
        height : 100%; 
        visibility : hidden;
    }
    div.ArticleImgHP-container { 
        width : 170px;
        height : 112px;
        background-image: url('../images/loading-circle.gif');
        background-position: center center;
        background-repeat: no-repeat;
    }

的jQuery

     $(document).ready(function () {
        // $("img #MainContent_rpt4x42_imgTopFourImg2_1").bind("load", function () { $(this).show(); });
           $("img.ArticleImgHP").bind("load", function () { $(this).css("visibility", "visible"); });


     });

我已将实际图像包裹在div标签内,我想显示此div标签的背景图像,直到实际图像被下载。我无法使其正常工作。在这方面,我将不胜感激。

我试图在jsFiddle上运行相同的东西它不起作用http://jsfiddle.net/t5d39/13/

1 个答案:

答案 0 :(得分:0)

通过将类添加到div标签

已解决

<div id="ArticleImgHP-container"  class="ArticleImgHP-container">
相关问题