Solved

Use the ClientScriptManager.RegisterForEventValidation

Posted on 2008-10-02
6
8,354 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:hbash
  • 3
  • 3
6 Comments
 
LVL 13

Expert Comment

by:SameerJagdale
Comment Utility
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:hbash
Comment Utility
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
Comment Utility
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:hbash
Comment Utility
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
Comment Utility
hope you got it right.
0
 
LVL 1

Author Comment

by:hbash
Comment Utility
Between your link and noodling around it is working. thanks.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now