只能在执行Render() 的过程中调用 RegisterForEventValidation
2010-12-16 09:45
387 查看
将页面上的gridview导出到excel中时会遇到这样一个问题:“只能在执行
Render() 的过程中调用 RegisterForEventValidation”
解决的方法有两种:
第一种:在Web.Config文件中:在<system.web></system.web>标记中添加如下代码:<不推荐>
<system.web>
<pages enableEventValidation="false"> </pages>
</system.web>
第二种:在具体的.aspx页面的源代码中修改代码,如下:
<%@ Page Language="C#"Inherits=" OutputData" AutoEventWireup="true"
CodeFile=" OutputDataThree.aspx.cs"
EnableEventValidation="false"%>
EnableEventValidation
默认值为true,它将启动事件验证。此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。
另外,如果页面含有一个linkbutton,并在后台创建对应的Click事件处理程序,此时想要将页面的table导出到excel时,也会报出上述同样的错误,此时解决方法有两种:
第一种:在Click事件处理中,将linkbutton的Visible设置成false
第二种:设置<@Page EnableEventValidation="false">
修改完毕后再次运行程序,又可以正确响应事件。关于出现的异常,可以认为在输出时候没有包含linkbutton,可是再提交到后台的时候却有相应的内容,前后不一致,所以在开启事件校验的情况下.NET抛出了异常。
Render() 的过程中调用 RegisterForEventValidation”
解决的方法有两种:
第一种:在Web.Config文件中:在<system.web></system.web>标记中添加如下代码:<不推荐>
<system.web>
<pages enableEventValidation="false"> </pages>
</system.web>
第二种:在具体的.aspx页面的源代码中修改代码,如下:
<%@ Page Language="C#"Inherits=" OutputData" AutoEventWireup="true"
CodeFile=" OutputDataThree.aspx.cs"
EnableEventValidation="false"%>
EnableEventValidation
默认值为true,它将启动事件验证。此功能验证回发或回调事件的参数是否来源于最初呈现这些事件的服务器控件。
另外,如果页面含有一个linkbutton,并在后台创建对应的Click事件处理程序,此时想要将页面的table导出到excel时,也会报出上述同样的错误,此时解决方法有两种:
第一种:在Click事件处理中,将linkbutton的Visible设置成false
第二种:设置<@Page EnableEventValidation="false">
修改完毕后再次运行程序,又可以正确响应事件。关于出现的异常,可以认为在输出时候没有包含linkbutton,可是再提交到后台的时候却有相应的内容,前后不一致,所以在开启事件校验的情况下.NET抛出了异常。
相关文章推荐
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render(); )
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- C# asp.net中导出Excel表时总出现"只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误
- 异常“只能在执行Render()的过程中调用RegisterForEventValidation”的解决办法
- 只能在执行Render() 的过程中调用 RegisterForEventValidation
- 问题:只能在执行 Render() 的过程中调用 RegisterForEventValidation;结果:只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render(); )
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation;
- GridView导入至EXCEL (报错处理:只能在执行 Render() 的过程中调用 RegisterForEventValidation)
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called durin
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 执行Render()方法时出现 "只能在执行 Render() 的过程中调用 RegisterForEventValidation;"错误
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render()
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation
- 只能在执行Render() 的过程中调用 RegisterForEventValidation;
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation(RegisterForEventValidation can only be called during Render()
- 当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误
- 只能在执行 Render() 的过程中调用 RegisterForEventValidation