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
Solved

Use the ClientScriptManager.RegisterForEventValidation

Posted on 2008-10-02
6
8,414 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
  • 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
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

856 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