Necessity, the mother of invention

  • Twitts

    Error: Twitter did not respond. Please wait a few minutes and refresh this page.

  • RSS My Reader

    • An error has occurred; the feed is probably down. Try again later.
  • Top Clicks

  • Advertisements
  • Visitor Map

    Locations of Site Visitors
  • Flag Counter

    free counters

Show loader on page load in

Posted by Navi's on March 24, 2011

To show loader while page is loading we have to use bellow code snippet. put this code on your master page or page. And overrride the OnLoad and Render methods.

protected override void OnLoad(EventArgs e)
        if (!IsPostBack)
            Response.Buffer = false;
            Response.Write("<div id='divImage'><div style='float: right;'><img src='loader.gif' />Please wait...</div></div>");
    protected override void Render(HtmlTextWriter writer)
        if (!IsPostBack)

and to hide loader we uses bellow javascript code snippet. Put this code at the end of page

<script language="javascript" type="text/javascript">
                var divLImage =  document.getElementById("divImage")
                if (divLImage != null && typeof(divLImage ) != 'undefined')
                        divLImage .style.display="none";
                        divLImage .parentNode.removeChild(divLoadingMessage);

css for loader div

#divImage {
     position: absolute;
    padding: 4px;
    top: 0px;
    right: 0px;
    color: gray;
    font-size: 13px;
    font-family: Verdana, Helvetica, Arial, sans-serif;
    width: 150px;
    font-weight: bold;

Whenever you request any page it’ll show loader on that page during load.
That’s it 🙂


2 Responses to “Show loader on page load in”

  1. Syed Nasir said

    Nice post.

  2. swapnil said

    best guru

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: