Click here to Skip to main content
15,885,244 members
Please Sign up or sign in to vote.
2.13/5 (7 votes)
See more:
:(( Hi all,
Iam getting this error while transferring data from gridview to excel, can any one suggest me the solution"RegisterForEventValidation can only be called during Render();"
Posted
Updated 15-Oct-16 1:25am

Try this,

Set EventValidation to false for the page and also override VerifyRenderingInServerForm in code behind,
public override void VerifyRenderingInServerForm(Control control)
{

}
 
Share this answer
 
Comments
Chinwendu 25-Apr-14 6:53am    
Setting the page EventValidation to false helped solved my challange.
hi,
i also faced with the same problem before and finally with the following changes my problem solved.
please check

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Records.aspx.cs" Inherits="Records" 
MasterPageFile="~/Master.master"  EnableEventValidation="false" %>


public override void VerifyRenderingInServerForm(Control control)
    {
        /* Confirms that an HtmlForm control is rendered for the specified ASP.NET
           server control at run time. */
    }
 
Share this answer
 
v2
Comments
kiransolkar 29-Feb-12 6:39am    
it works thnx
R. Ramprakash 30-Sep-13 0:55am    
yep..its working now :) tnq
pratheeshsaji 8-Mar-13 7:46am    
thanq so much..
manojmadhuranga 18-Dec-13 2:26am    
Thanks..It worked for me..just doing this..[ EnableEventValidation="false" ]
hey just set viewstate false

//Turn off the view state
this.EnableViewState = False;
//Remove the charset from the Content-Type header
Response.Charset = String.Empty;

and
EnableEventValidation="false"
 
Share this answer
 
C#
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" enableEventValidation ="false" Inherits="Default" %>





also add

C#
public override void VerifyRenderingInServerForm(Control control)
{

}
 
Share this answer
 
v2
Comments
King Fisher 7-Nov-13 7:09am    
is this a good way to solve this problem..??
shadab.khan9905 7-Mar-18 14:15pm    
Thanks its working..
Yes this is right we need to do the following:

1. .cs file add the following: //Change the Header Row back to white color
// HeaderRow-Style=#FFFFFF


// Style.Add("background-color", '#-d-f-5-015');


2. //.AS-PX file add the following:

// Enable-Event-Validation="false" inside <%@ Page directive

This makes it work like a charm!
 
Share this answer
 
Comments
[no name] 15-Oct-16 7:27am    
Oh very well done. Resurrecting a SEVEN year old already answered question just to get those oh-so-valuable worthless internet points.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900