• 只能在执行 Render() 的过程中调用 RegisterForEventValidation


     

    “/Website1”应用程序中的服务器错误。


    只能在执行 Render() 的过程中调用 RegisterForEventValidation;

    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

    异常详细信息: System.InvalidOperationException: 只能在执行 Render() 的过程中调用 RegisterForEventValidation;

    源错误:

    行 41:         if (gvWorkTicketRecord.Rows.Count > 0)
    行 42:         {
    
    行 43: objExportToFile.ToExcel(gvWorkTicketRecord, "WorkTicketReports");
    行 44:         }
    行 45:         else


    源文件: d:\Projects\Engtek\System\Report\Manufacture\WorkTicketReports.aspx.cs    行: 43

    堆栈跟踪:

    [InvalidOperationException: 只能在执行 Render() 的过程中调用 RegisterForEventValidation;]
       System.Web.UI.ClientScriptManager.RegisterForEventValidation(String uniqueId, String argument) +8642059
       System.Web.UI.WebControls.CheckBox.RenderInputTag(HtmlTextWriter writer, String clientID, String onClick) +237
       System.Web.UI.WebControls.CheckBox.Render(HtmlTextWriter writer) +179
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.WebControls.TableCell.RenderContents(HtmlTextWriter writer) +57
       System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
       System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.WebControls.Table.RenderContents(HtmlTextWriter writer) +206
       System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +32
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
       System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
       System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +10
       System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer, Boolean renderPanel) +224
       System.Web.UI.WebControls.GridView.Render(HtmlTextWriter writer) +33
       System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
       System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
       Insus.NET.ExportToFile.ExportFileParse(WebControl webCtrl, String fileName, String typeName) +299
       Insus.NET.ExportToFile.ExportToExcelFile(WebControl webCtrl, String fileName) +76
       Insus.NET.ExportToFile.ToExcel(WebControl webCtrl, String fileName) +41
       System_Report_Manufacture_WorkTicketReports.btnReportToExcel_Click(Object sender, EventArgs e) in d:\Projects\Engtek\System\Report\Manufacture\WorkTicketReports.aspx.cs:43
       System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
       System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
       System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    

    版本信息: Microsoft .NET Framework 版本:2.0.50727.3053; ASP.NET 版本:2.0.50727.3053

    解决方法,在Page中添加一个属性EnableEventValidation,设定值为false即可。

    <%@ Page Language="C#" EnableEventValidation="false" ...

  • 相关阅读:
    XML解析
    资源管理
    Android中的动态字符串的处理
    消息提示的三种方式
    程序调控和监视(Logcat,Debug)
    选择改变事件OnCheckedChange
    递归和非递归分别实现求n的阶乘
    递归和非递归分别实现strlen
    编写一个函数 reverse_string(char * string)实现:将参数字符串中的字符反向排列 。(递归实现)
    写一个递归函数DigitSum(n),输入一个非负整数,返回组成它的数字之和
  • 原文地址:https://www.cnblogs.com/insus/p/1501243.html
Copyright © 2020-2023  润新知