Adding an animated gif while a slow page is loading is a fairly straightforward, but in ASP.NET when you do a postback the animated gif will freeze. To get around this you need to reset the image src oclient side after the postback has occured, which can be done using the setTimeout command. Add OnClientClick="loadImg();" to the button loading the slow page and add this markup to the same page:

<
img id="loading" src="/images/loading.gif" alt="" style="display:none;"/>

<script type="text/javascript">
function loadImg() {
document.getElementById(
'loading').style.display = "";
setTimeout(
'document.images["loading"].src="/images/loading.gif"', 200);
}
</script>
13/2/2011 02:10:31 pm

Thank you for sharing this wonderful article.

20/2/2011 04:34:34 pm

Life finds its wealth by the claims of the world, and its worth by the claims of love.


Comments are closed.