本文介绍了如何计算方法的执行时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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);
}
protected void btnExcel_Click(object sender, EventArgs e)
{
view_report();
}
我的上述代码在x秒后是可启用的按钮.
我想要的是,在计算出方法视图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?
推荐答案
protected void btnExcel_Click(object sender, EventArgs e)
{
view_report();
}
我的上述代码在x秒后是可启用的按钮.
我想要的是,在计算出方法视图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?
DateTime startTime = DateTime.Now;
ViewReport();
TimeSpan timeTaken = DateTime.Now - startTime;
那应该可以解决问题.
-Dom
That should do the trick.
-Dom
这篇关于如何计算方法的执行时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!