[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 268
  • Last Modified:

ClientScriptManager..

can someone give me example how to use that  clientscriptmanager.registerforeventvalidation, because I get this error , but i dont want to set enableeventvalidation to false for security reason.. but I dont know how to use that to eventvalidation either, I need an example..

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.
0
1jaws
Asked:
1jaws
  • 8
  • 7
1 Solution
 
sunithnairCommented:
When do you get this error? Try disabling event validation in the page/web.config by setting it to false and see if it solves your problem but this is not recommended for security purpose
0
 
1jawsAuthor Commented:
yeah I dont want that at all, the other option is always use the ClientScriptManager .. but I dont know how to use that in my code, I need to example cannot find it, I probably will need to use that on my button click,...
0
 
sunithnairCommented:
What else are you dping on your page? Are you modifying any data using javasscript?
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!

 
1jawsAuthor Commented:
I use RadAjaxPanel
that's it and validations such as requiredfiled validatior. have dropdowns and textboxes
0
 
sunithnairCommented:
Register your controls (like dropdowns and textboxes) like this in the overridden render event like this
protected override void Render(HtmlTextWriter writer)
{
Page.ClientScript.RegisterForEventValidation(DropDownList1.UniqueID);
Page.ClientScript.RegisterForEventValidation(DropDownList2.UniqueID);
Page.ClientScript.RegisterForEventValidation(ListBox1.UniqueID);
base.Render(writer);
} 

Open in new window

0
 
1jawsAuthor Commented:
should I put that on the button click event? or seperate code?because error happens on the button click event
0
 
sunithnairCommented:
just put it as a seperate function. The error happens in button click event because the postback happens when you click the button.
0
 
1jawsAuthor Commented:
I did put that in seperate one but I only did it for the dropdowns, do I need that for the textboxes too? because dropdown's didnt work...
0
 
1jawsAuthor Commented:
also just notice I have a javascript actually running on that page, for the pop up window...maybe that is causing..?
0
 
1jawsAuthor Commented:
that didnt work either
0
 
sunithnairCommented:
You need to do it for all the server controls and also if you are trying to modify any text using javascript try disabling the viewstate for that control.
0
 
1jawsAuthor Commented:
i put that for the all the server controls and didnt work, what about the javascript of the linkbutton I have ihyperlink and imagebutton but those not happening anything on the postback, do I need to still add them to server control and disable viewstate? if yes, how to do that disabling?
0
 
sunithnairCommented:
i dont think you need to add them but you can try if that works or not. disabling viewstate is settng the attribute (enableviewstate) of the server controls to false

<asp:TextBox ID="txtTest" runat="false" enableviewstate="false" />
0
 
sunithnairCommented:
If you can actually paste some part of your code i would be able to look at it.
0
 
1jawsAuthor Commented:
sunith, you never knew it was nothing do it, I had to take out the buttons inside the my ajax panel and worked even without that code above...
THank you sooo much for helping me all the time.. I appreacited!!!
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 8
  • 7
Tackle projects and never again get stuck behind a technical roadblock.
Join Now