Click here to Skip to main content
15,914,820 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have disable the button using javascript
i have this code ,

C#
protected void btnExcel_Click(object sender, EventArgs e)
    {      
        view_report();
      
        try
        {
            Rpt.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, true, "Employee Report");


        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            ex = null;
        }
        finally
        {
         btnExcel.enabled=true;
            Rpt.Dispose();
            Rpt.Close();
        }
       
    
    }


in try block got the exception ,
Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack

so btnExcel.enabled=true;
this statement not executed in finally block
Posted
Updated 28-May-12 21:18pm
v2

Might be exception in your Funciton Rpt.ExportToHttpResponse()

comment this method and check is application running and button is enabled or not?

i suggest you to check your Function.

if you remove try catch block and run application then you will get actual location where the error is.
 
Share this answer
 
v2
Comments
Member 8861818 17-May-12 3:18am    
yes exception in the Funciton Rpt.ExportToHttpResponse
if i comment this function then btn enable but
i can't comment this funtion as it gives the repot in pdf format
only execution of function i have to enable button.
in try block got the exception ,
You are getting an exception in your method ExportToHttpResponse. Based on what are you doing, I can guess the code and I believe you are doing a Response.End in it. Debugging in VS will tell you the exact line.

In place of Response.End you have to use HttpContext.Current.ApplicationInstance.CompleteRequest method to bypass the code execution to the Application_EndRequest event.

Look here for details: Microsoft Support: ThreadAbortException Occurs If You Use Response.End, Response.Redirect, or Server.Transfer[^]
 
Share this answer
 
Comments
Member 8861818 17-May-12 3:26am    
i debugg in vs but unable to find Response.End
pls help
Sandeep Mewara 17-May-12 3:45am    
You say no Response.End or Response.Redirect in your workflow? Sure? Used F11 in debugging?
Member 8861818 17-May-12 4:47am    
I press F11 on function Rpt.ExportToHttpResponse() then control remain on function Rpt.ExportToHttpResponse() itself.

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