Friday, May 3, 2013

RegisterForEventValidation can only be called during Render in

In previous post i have given how to Export Gridview data to excel in,Read data from excel file,Bind excel data to gridview,Export gridview data to word document.In this post i will explain how to resolve the RegisterForEventValidation error while generating reports from gridview.To resolve this kind of  error we need to render the controls then add the set the EnableEventValidation property to False at Page directive(you see the highlighted text).

Code behind:
This peace of code have to add in class.It will render the control to desired response while working with controls

public override void VerifyRenderingInServerForm(Control control)


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportToWord.aspx.cs" Inherits="ExportToWord" EnableEventValidation="false"

No comments: