Click here to Skip to main content
15,845,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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-----------------------------------
C#
protected void Page_Load(object sender, EventArgs e)
    {
btnExcel.Attributes.Add("onclick", " this.disabled = true; " + ClientScript.GetPostBackEventReference(btnExcel, null) + ";");
    }


C#
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);

}
}
Posted
Comments
Binu Varghese K 12-Jun-12 2:46am    
I didnt get your problem. But you ps try this..
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJSFunction", "myEnablefunction();", true);

1 solution

I think your code is causing Thread abort exception. Please go though below link which explains the solution to similar problem of yours.
http://forums.asp.net/t/984756.aspx/1[^]

Another reference:

http://weblogs.asp.net/varadam/archive/2011/05/18/unable-to-evaluate-expression-because-the-code-is-optimized-or-a-native-frame-is-on-top-of-the-call-stack.aspx[^]
 
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