Click here to Skip to main content
15,885,278 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
hi,i want when a user click on the button,linkbutton or tabcontainer a loading image should be display,but if the response time is less than 2 sec for a gridview to get fully loaded & displayed,that time i dont want the loading image should be display .
i am showing the loading image through javascript,as

C#
function onBeginRequest() 
{      
        $get('container').style.cursor = 'wait';
        $find('mdlPopupPleasewait').show();
}

i did some rnd and i found this
C#
protected void Application_BeginRequest(object sender, EventArgs e)
        {
            Context.Items.Add("Request_Start_Time", DateTime.Now);
        }
protected void Application_End(object sender, EventArgs e)
      {
          TimeSpan tsDuration = DateTime.Now.Subtract((DateTime)Context.Items["Request_Start_Time"]);
          Context.Response.Write("<b>Request Processing Time: From Global.asax file " + tsDuration.ToString());

      }
Posted
Updated 9-Aug-12 8:52am
v2
Comments
aidin Tajadod 9-Aug-12 18:35pm    
Are you calling server side async? in this case you are able to show some PB until get the response back. in this case just wait for 2 seconds before showig you PB and if you did not get any response during this 2 sec, then show your Progress Bar.

If you aren't using Ajax, showing PB does not make sense! because your whole page is going to reload and if you show PB before loading the page, it will go away and if you show it after loading the page, then you have your data and it seems to be useless! (I have heard about sending data as they become ready in the server side, but I haven't tried it and I think it does not apply to your situation.)

I'm a little confused about what exactly you are doing, but I'll make some assumptions.

If you are using an UpdatePanel to do your AJAX postbacks, you can use an UpdateProgress control to show something after a specified number of time (e.g., 2 seconds).

Supposing you have an UpdatePanel called upSearch, your UpdateProgress control would look something like this:
ASP.NET
<asp:UpdateProgress runat="server" AssociatedUpdatePanelID="upSearch" DisplayAfter="2000">
  <ProgressTemplate>
    <div class="search_progress">
      Updating...
    </div>
  </ProgressTemplate>
</asp:UpdateProgress>
 
Share this answer
 
Comments
AmitGajjar 10-Aug-12 0:41am    
5+ as i do not know about DisplayAfter property of UpdateProgress.

thanks.
bbirajdar 10-Feb-13 11:53am    
+5 from me too
XML
<head >

<script  type="text/javascript" src="jquery-1.9.1.js" >
</script>

<script type="text/javascript" >
var clockStart;
var clockEnd;
$(document).ready(function() {
alert('abc')
  startday = new Date();
  clockEnd = startday.getTime();
clockStart=getCookie("Resp_Time_12");
  document.getElementById("<%=TextBox1.ClientID%>").value=(clockEnd-clockStart)/1000;

});

$(window).unload(function() {
  startday = new Date();
  clockStart = startday.getTime();
setCookie("Resp_Time_12", clockStart, 1);


});

function setCookie(c_name, value, expiredays) {
     var exdate = new Date();
     exdate.setDate(exdate.getDate() + expiredays);
     document.cookie = c_name + "=" + escape(value) +
 ((expiredays == null) ? "" : ";expires=" + exdate.toUTCString());
 }

function getCookie(c_name) {
     if (document.cookie.length > 0) {
         c_start = document.cookie.indexOf(c_name + "=");
         if (c_start != -1) {
             c_start = c_start + c_name.length + 1;
             c_end = document.cookie.indexOf(";", c_start);
             if (c_end == -1) c_end = document.cookie.length;
             return unescape(document.cookie.substring(c_start, c_end));
         }
     }
     return "";
 }



</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900