0
protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            Response.Write("<div id=\"loading\" style=\"position:absolute; width:100%; text-align:center; top:300px;\"><img src=\"https://site here/images/loading.gif\" border=0></div>");
            Response.Flush();
            LoadDirs();
            Response.Write("<script>document.getElementById('loading').style.display='none';</script>");
        }
    }

LoadDirs() builds a List< TreeNode > and then adds them to the TreeView.

It seems the 2nd Write to clear the loading image happens right away. I don't want the loading image to disappear until LoadDirs() is completely finished.

Tsukasa
  • 6,342
  • 16
  • 64
  • 96
  • Ummm..you have to use ajax for something like this. http://stackoverflow.com/questions/7704171/asp-net-display-loading-message-while-update-panel-is-updating – Rick S Apr 29 '14 at 15:27
  • Is there a way to trigger it on Page_Load and not a button press? – Tsukasa Apr 29 '14 at 17:05
  • For Page_Load, I think your best bet is to try this: http://stackoverflow.com/questions/911059/asp-net-3-5-display-updateprogress-during-page-load – Rick S Apr 29 '14 at 17:17

1 Answers1

2

I think you should use UpdatePanel and UpdateProgress

An introduction here => http://msdn.microsoft.com/en-us/library/vstudio/bb386421(v=vs.100).aspx

binard
  • 1,726
  • 1
  • 17
  • 27
  • Is there a way to trigger it on Page_Load and not a button press? – Tsukasa Apr 29 '14 at 17:10
  • Yes, with jQuery you can set a bunch of things to happen once the page has completed it's load, including invoking a PageMethod to retrieve some data from the server in the background. – Dean.DePue Apr 29 '14 at 17:27