?
Solved

Use the ClientScriptManager.RegisterForEventValidation

Posted on 2008-10-02
6
Medium Priority
?
8,533 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
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!

 
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 1500 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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