【发布时间】:2012-06-13 15:53:12
【问题描述】:
当我单击 btn 控件时,使用 javascript 禁用 btn,然后 btn 单击事件调用。 在 btn 点击事件中,我编写代码,为我使用方法提供 excel/pdf 格式的报告 ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Report Name") 这给了我例外所以在这个方法之后 或者当我写 btn.enable=true 时最终阻塞;或使用 javascript 然后不执行。 异常是无法评估表达式,因为代码已优化或本机框架位于调用堆栈顶部
即我必须在生成报告时启用 btn。 当这个方法被执行时 ExportToHttpResponse() 我得到了报告 所以在这个方法之后我必须启用 btn 控制
protected void Page_Load(object sender, EventArgs e)
{
btnExcel.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnExcel, null) + ";");
}
protected void btnExcel_Click(object sender, EventArgs e)
{
view_report();
try
{
Rpt.ExportToHttpResponse(ExportFormatType.Excel, Response, true, " Reportname");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
ex = null;
}
finally
{
btnExcel.Enabled = true;
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJSFunction", "myEnablefunction()", true);
}
}
【问题讨论】:
-
请包含javascript
myEnablefunction()的内容。 -
function myEnablefunction(){ btnExcel.disabled=false;}
标签: asp.net