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

RegisterForEventValidation can only be called during Render();

60
0
RegisterForEventValidation can only be called during Render();
RegisterForEventValidation can only be called during Render();

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

RegisterForEventValidation can only be called during Render();
RegisterForEventValidation can only be called during Render();
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" %>

As you can see in above solution, I’ve just disabled EnableEventValidation attribute. It’ll work. That’s it!

Previous articleControl ‘GridView1’ of type ‘GridView’ must be placed inside a form tag with runat=server
Next articleHow to use AJAX in Asp.net with Example?
Hi there, I am Mayank, the man behind Technical Mack. I started AspnetO with a motive to educate people on various programming languages ranging from beginners to expert level. Through this blog, I aim to provide more insightful content.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

20 + eighteen =