I am working on a functionality where i can show Loading Progress using animated image till actual image is downloaded.
I have a page which has lots of image i loop through the record and display them using repeater control. Below is teh example of the code 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"); });
});
I have wrapped the actual image inside a div tag and i want to show background image of this div tag till actual image is downloaded.I am not able to get it working. I would appreciate help in this regard.
I am trying to make the same thing run on jsFiddle it is not working http://jsfiddle.net/t5d39/13/
RESOLVED it by adding the class to div tag