0
當我點擊btn控制禁用btn使用JavaScript然後btn單擊事件調用。 裏面的BTN點擊事件我寫的代碼,它給了我在Excel/PDF格式的報告,我使用的方法 ExportToHttpResponse(ExportFormatType.Excel,Response,true,「Report Name」)這給我例外,所以在此方法之後 或finally塊當我寫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()'的內容。 –
函數myEnablefunction(){btnExcel.disabled = false;} – RakeshKumar