Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/34.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# UpdatePanel中出错:无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部_C#_Asp.net_Gridview_Updatepanel_Scriptmanager - Fatal编程技术网

C# UpdatePanel中出错:无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部

C# UpdatePanel中出错:无法计算表达式,因为代码已优化或本机框架位于调用堆栈顶部,c#,asp.net,gridview,updatepanel,scriptmanager,C#,Asp.net,Gridview,Updatepanel,Scriptmanager,我使用一个带有Gridview的UpdatePanel。计时器正在检查Gridview中的某些内容。在Gridview中,我生成一列用于查看上载: <asp:TemplateField HeaderText="Zeichnung" ItemStyle-HorizontalAlign="Center"> 单击按钮开始下载: Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.Clear

我使用一个带有Gridview的UpdatePanel。计时器正在检查Gridview中的某些内容。在Gridview中,我生成一列用于查看上载:

<asp:TemplateField HeaderText="Zeichnung" ItemStyle-HorizontalAlign="Center">
单击按钮开始下载:

Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.Clear();
Response.AppendHeader("Content-Disposition", "attachment;Filename=" + Upload);
Response.TransmitFile(Page.MapPath("App_data/OPL/Upload/" + Upload));
Response.End();
在我将gridview放入UpdatePanel之前,一切都很好。现在它抛出错误:

无法计算表达式,因为代码已优化或本机帧位于调用堆栈顶部

我试图用HttpContext.Current.ApplicationInstance.CompleteRequest替换Response.End;但一切都没有改变

正如这里所写的,这是回发的问题。解决办法似乎是

protected void Page_Load(object sender, EventArgs e) {
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterPostBackControl(this.btnExcelExport);
//Further code goes here....
}
但是我不能添加这段代码,因为按钮是生成的,而不是在gridview中给出的。我试图添加scriptManager.RegisterPostBackControlthis.btn_Upload;但他没有找到按钮


我怎样才能解决这个问题?感谢

一个可能的解决方案是将gridview作为一个整体注册为postback control.ScriptManager.RegisterPostBackControlthis.gvr

protected void Page_Load(object sender, EventArgs e) {
ScriptManager scriptManager = ScriptManager.GetCurrent(this.Page);
scriptManager.RegisterPostBackControl(this.btnExcelExport);
//Further code goes here....
}