Solved

Use the ClientScriptManager.RegisterForEventValidation

Posted on 2008-10-02
6
8,450 Views
Last Modified: 2008-10-14
I have a Visual Studio 2005 asp app with a GridView.  In the row_created event I do the following :

            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline';this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFF00'")
            e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';this.style.backgroundColor=this.originalstyle;")
            e.Row.Attributes("onclick") = ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" & e.Row.RowIndex)

On the row click,  I get an error pasted in code snippet section.
Please advise.
Thanks,
Howard




Server Error in '/' Application.
--------------------------------------------------------------------------------
 
Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation. 
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.ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
 
Source Error: 
 
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
 
Stack Trace: 
 
 
[ArgumentException: Invalid postback or callback argument.  Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page.  For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them.  If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.]
   System.Web.UI.ClientScriptManager.ValidateEvent(String uniqueId, String argument) +2132728
   System.Web.UI.Control.ValidateEvent(String uniqueID, String eventArgument) +108
   System.Web.UI.WebControls.GridView.RaisePostBackEvent(String eventArgument) +28
   System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +177
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1746

Open in new window

0
Comment
Question by:Howard Bash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22631404
2 things you can try:
- Use the Page.ClientScript.RegisterForEventValidation(ctrl. UniqueID)
- Set the <pages EnableEventValidation="false" &/> in the web.config
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 22692536
Where?
and,
Do you mean something like:

            e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand';this.style.textDecoration='underline'; _
                this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFF00'")

            e.Row.Attributes.Add("onmouseout", "this.style.textDecoration='none';this.style.backgroundColor=this.originalstyle;")
            e.Row.Attributes("onclick") = ClientScript.GetPostBackClientHyperlink(Me.GridView1, "Select$" & e.Row.RowIndex)
            Page.ClientScript.RegisterForEventValidation(GridView1. UniqueID)
0
 
LVL 13

Expert Comment

by:SameerJagdale
ID: 22693550
quite obvious .. first one, Page.ClientScript.RegisterForEventValidation will go to page load and i have already mentioned second one (web.config).
check the link for example:
http://msdn.microsoft.com/en-us/library/ms366515.aspx
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Howard Bash
ID: 22694288
First,  if it was obvious, I would not have asked you to clarify, no?  That is obvious.  However, thanks for the link.
0
 
LVL 13

Accepted Solution

by:
SameerJagdale earned 500 total points
ID: 22701442
hope you got it right.
0
 
LVL 1

Author Comment

by:Howard Bash
ID: 22717910
Between your link and noodling around it is working. thanks.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question