Click here to Skip to main content
15,922,407 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
protected void Page_Load(object sender, EventArgs e)
{
    int x = 1000;
    BtnPrint.Attributes.Add("onclick", "javascript:"
      + BtnPrint.ClientID + ".disabled=true;"
      + Page.ClientScript.GetPostBackEventReference(BtnPrint, null));

    //Renable the button after x seconds
    string Script = @"<script language ="'javascript'">
       window.setTimeout('enable()', " + x.ToString() + ")
       function enable()
{
   document.getElementById('$BTNAME').disabled = 0;
}
      </script>";

    Script = Script.Replace("$BTNAME", BtnPrint.ClientID);
    Page.ClientScript.RegisterStartupScript(GetType(), "script", Script);
}


C#
protected void btnExcel_Click(object sender, EventArgs e)
   {

 view_report();

}


my above code is renable button after x seconds.
what i want is , renable button after calculating execution time of method view report()
this how can i do?
Posted
Updated 2-May-12 22:06pm
v2

Try this:

C#
DateTime startTime = DateTime.Now;
ViewReport();
TimeSpan timeTaken = DateTime.Now - startTime;


That should do the trick.

-Dom
 
Share this answer
 
Comments
Rahul Rajat Singh 3-May-12 4:40am    
But i am guessing he want to calculate the time prior to executing this method so that for the time method is executing he can keep the button disabled.
Member 8861818 3-May-12 5:07am    
yes u r rights
By using System.Diagnostics namespace you will count excution time of a method
ex:
Dim st = Stopwatch.StartNew()
methode()
st.stop
VB
Response.Write("<br/> time taken")
      Response.Write((CDbl(st.Elapsed.TotalMilliseconds * 1000000) / 10000000).ToString("0.00 ns"))

may be it will help you
 
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