Introduction:
Here I will explain how to solve the problem RegisterForEventValidation can only be called during Render(); during export of gridview to excel or word or csv using asp.net.
Description:
Here I will explain how to solve the problem RegisterForEventValidation can only be called during Render(); during export of gridview to excel or word or csv using asp.net.
Description:
In previous post I explained clearly how to show export gridview data to excel,word,notepad and csv using asp.net Export gridview data to Excel,Word . During export a gridview data to excel, word, notepad or csv I got error like
RegisterForEventValidation can only be called during Render();
This error occurs whenever we are trying to render control to response. To solve this problem I have added EnableEventValidation="false" to @Page directive of aspx page that should be just like this
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ExportGridviewtoExcel.aspx.cs" Inherits="ExportGridviewtoExcel" EnableEventValidation="false"%> |
By Setting EnableEventValidation="false" property to @Page directive of aspx page the problem has solved automatically.
I hope it helps to solve your problem.
Happy Coding………
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
37 comments :
Hi, I tried that change as specified here, but I still get the same error. I am using the functionality in a user control and the user control is placed inside the main aspx page where I put this property. Are there any other changs?
Wow, so you disable validation and you call that "solving the problem".
Worked great once I included the fixes. Thanks for this, solved my current 'crisis'
That fixed it, THANKS!!!
sir gn, i am happy see your website.Am freshers to asp.net. I need your help. Now am creating master table screen . In that employee screen( branch id* is foreign key ) in aspx file, i want to show branch name * in dropdownlist.But in the gridview branch id only to be stored .Plz help me @ kamalakannan591989@gmail.com
Hello, I am Hitesh Gaur.(programmer)
It's a way to solve the problem Mr. Dasari. Before any one tries this I suggest, it will expose your web app/site to some attacks.
Yes, It is working.Thanks
Thanq very much sir,its working great
From Microsoft:
Security Note
This feature reduces the risk of unauthorized or malicious postback requests and callbacks. It is strongly recommended that you do not disable event validation.
Extender control 'ModalPopupTicket' is not a registered extender control. Extender controls must be registered using RegisterExtenderControl() before calling RegisterScriptDescriptors(). Parameter name: extenderControl
how can i solve this error...plz help me....as eary as possible
I don't know how to use CSV!!!
Yes dude it's work.... you great....
is it not true that disabling EnableEventValidation will make your site vulnerable to XSS attacks. i think one should use excel converting libraries.
Unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type 'iTextSharp.text.html.simpleparser.TableWrapper'.
I have solve the problem. Thanks a lot!
I sir i am using u r code its working perfectly for grid view but i have some textbox on top of gridview i want export those values to pdf.
I have given like TextBox3.RenderControl(hw);
but its not showing in the pdf document..can u tell me why..and thanks in advance
if u still getting error then keep this code in codebehind file and with EnableEventValidation="false"
Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
' Verifies that the control is rendered
End Sub
I have a doubt Dasari...
your code is perfect but its doesn't work when "sorting" operation performed on grid..
and it doesn't work when grid is empty..
Hello suresh
This is Anupam Singh Jadoun
i am getting error
ould not find a part of the path 'C:\Program Files (x86)\Common Files\Microsoft Shared\DevServer\10.0\Images\16062013969.jpg'
Thanks for this once again..
I have got dis error " unable to cast object of type 'iTextSharp.text.html.simpleparser.CellWrapper' to type ''iTextSharp.text.Paragraph "
thank u Suresh Ji.....i am filling lucky to joined your group....
nice sir helps me a lot your coding's are awesome
your code is perfect but its doesn't work when "sorting" operation performed on grid..
and it doesn't work when grid is empty..
thxx
Its awesome page ..each and every query related to ASP.NET will be solved only here...
again thanx sir ji....
we have use your code
But This Give a Error
The remote server returned an error: (500) Internal Server Error.
thanks its solved
Its really very helpful..
but i am getting error "unable to evaluate expression because the code is optimized or a native frame"
i am trying to convert string into pdf file and save in a folder but i am not able to do this plz help. thank you
thanx dear it solved my problem keep on helping
Woowww It Work Thanx....
hello suresh it is working fine and when we saving into pdf the size of the image was in its original format i want to reduce the size of the image which was getting in the pdf, So can u plz help me in this issue
Thanks it works for me...
Could not load file or assembly 'itextsharp, Version=5.5.5.0, Culture=neutral, PublicKeyToken=8354ae6d2174ddca' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
regarding Grid to PDF
by manikandan
Getting error:
The number of columns in PdfPTable constructor must be greater than zero.
I am getting exception at htmlparser.Parse(sr); as input string not in a correct format
Note: Only a member of this blog may post a comment.