btn disable but not enable

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RakeshKumar
    New Member
    • Jun 2012
    • 1

    btn disable but not enable

    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 ExportToHttpRes ponse(ExportFor matType.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 ExportToHttpRes ponse() i got report so after this method i have to enable btn control

    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, " Reportname");
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex.Message);
            ex = null;
        }
        finally
        {                  
           btnExcel.Enabled = true;
            ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "CallJSFunction", "myEnablefunction()", true);
        }
    }
    js function is

    Code:
    function myEnablefunction()
    { 
    var BtnEx=document.getElementById("ctl00$ContentPlaceHolder$btnExcel");
    BtnEx.disabled=false;
    
    }
    Last edited by Frinavale; Jun 14 '12, 04:25 PM. Reason: Added code tags.
Working...