Solved

Use the ClientScriptManager.RegisterForEventValidation

Posted on 2008-10-02
6
8,483 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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

Technology Partners: 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!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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.
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

691 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