Link to home
Start Free TrialLog in
Avatar of 1jaws
1jawsFlag for United States of America

asked on

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.
Avatar of sunithnair
sunithnair

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
Avatar of 1jaws

ASKER

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,...
What else are you dping on your page? Are you modifying any data using javasscript?
Avatar of 1jaws

ASKER

I use RadAjaxPanel
that's it and validations such as requiredfiled validatior. have dropdowns and textboxes
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

Avatar of 1jaws

ASKER

should I put that on the button click event? or seperate code?because error happens on the button click event
just put it as a seperate function. The error happens in button click event because the postback happens when you click the button.
Avatar of 1jaws

ASKER

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...
Avatar of 1jaws

ASKER

also just notice I have a javascript actually running on that page, for the pop up window...maybe that is causing..?
Avatar of 1jaws

ASKER

that didnt work either
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.
Avatar of 1jaws

ASKER

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?
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" />
ASKER CERTIFIED SOLUTION
Avatar of sunithnair
sunithnair

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 1jaws

ASKER

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