无法计算表达式,因为代码在 ASP.NET 中打印页面时进行了优化

我收到“无法评估表达式,因为代码已优化”打印页面时出现异常。

对于打印,我使用字符串生成器附加 HTML 组件,然后将其放入 Literal 中,然后将 Literal 分配给 Session[“ctrl”]。我使用页面名称 Print.aspx 和辅助函数 PrintHelper

打印.aspx


protected void Page_Load(object sender, EventArgs e)

{

        try

        {

            Control ctrl = (Control)Session["ctrl"];

            PrintHelper.PrintWebControlStudentApp(ctrl);

        }

        catch(Exception ex)

        {

        }

 }

我在 Print.aspx 页面上收到错误,其中 catch() 引发异常:


无法计算表达式,因为代码已优化


侃侃尔雅
浏览 77回答 3
3回答

慕容森

检查Page.aspx页面,由于系统对母版页的某些依赖性,线程被中止。 谢谢

神不在的星期二

您使用调试版本吗?或者发布版本,而不是确保代码已优化。

富国沪深

ClientScript.RegisterStartupScript(typeof(Page), "onclick", "<script language=javascript>window.open('../Print.aspx','PrintMe','height=700px,width=700px,scrollbars=1');</script>");您的错误---无法计算表达式,因为代码是 优化注意:- 我认为...您收到错误只是因为页面没有以正确的方式重定向...在目的地string url="";// In this Line you have to add url in proper way ...so you can easliy redirect&nbsp;string dim = "toolbar=0,fullscreen=1,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,maximize=0,height=1000px";ScriptManager.RegisterStartupScript(this.Page, this.GetType(), Guid.NewGuid().ToString().Trim(), "window.open('" + url + "', 'Popup', '" + dim + "');", true);
打开App,查看更多内容
随时随地看视频慕课网APP