when i click btn control disable btn using javascript then btn click event call.
inside btn click event i write code which gives me report in excel/pdf format for that i use method
ExportToHttpResponse(ExportFormatType.Excel, Response, true, "Report Name") which gives me exception so after this method
or finally block when i write btn.enable=true; or use javascript then not executed.
exception is Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack
i.e. i have to enable btn when report is generated.
as this method get executed ExportToHttpResponse() i got report
so after this method i have to enable btn control
-----------my code-----------------------------------
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, " Report name");}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
ex = null;
}
finally
{
btnExcel.Enabled = true;
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJSFunction", "myEnablefunction()", true);
}
}