Home Asp.net RegisterForEventValidation can only be called during Render();

RegisterForEventValidation can only be called during Render();

9
0

Now here in this tutorial, I’ll explain how to solve the RegisterForEventValidation can only be called during Render(); error while exporting the gridview data in asp.net c# vb.net.

In my previous tutorials, I’d explained export all gridview data to word excel text pdf, export only selected rows from gridview to word excel text pdf, print gridview data on print button click and other more cracking tutorials on GridView, Asp.net here.

 

Error: RegisterForEventValidation In Asp.net

Control GridView1 of type GridView must be placed inside a form tag with runat=server

Server Error in ‘/’ Application.


RegisterForEventValidation can only be called during Render();

Description: An unhandled exception occurred during the execution of the current web request.
Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: RegisterForEventValidation can only be called
during Render();

Error Cause:

You might get this error while you are trying to render control to response during gridview data export to word, excel, pdf etc.

Error Solution:

We need to add EnableEventValidation=”false” in @Page directive on the top of the .aspx page.

Following is the sample code to resolve the RegisterForEventValidation error:

<%@ Page Language=”C#” CodeBehind=”ExportSelectedRowsExamples.aspx.cs”
AutoEventWireup=”true”  Inherits=”ExportToWordExcelPdf.ExportSelectedRowsExamples”
EnableEventValidation=”false” %>

LEAVE A REPLY

Please enter your comment!
Please enter your name here
Captcha verification failed!
CAPTCHA user score failed. Please contact us!