In my current ASP.NET 2.0 [AJAX] project, I came across this error
" 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."
After looking at the error message I immediately set enableeventvalidation="false" at page level and do away with the error but I faced other problem i.e. I was not able to retrieve values of my controls [only specific control] during post back. The scenario goes like this:
My asp.net page has got the following server controls
1. Textbox,
2. Drop down list
3. Button
4. Grid inside an Updatepanel
In the client side onchange event of the textbox control, AJAX web service call is made and based on the result the drop down list gets populated dynamically. Upon button click, my gridview control which is inside the updatepanel should populate [expected result]. I was not able to get the selected value of the drop down list during partial post back and I couldn't find the root cause immediately and at last after googling I got a good pointer about this issue is well explained by Scott Allen
http://odetocode.com/Blogs/scott/archive/2006/03/20/3145.aspx [Part 1]
http://odetocode.com/Blogs/scott/archive/2006/03/21/3153.aspx [Part 2]
At last I managed to get my expected results by introducing an hidden control where I set the dropdown list's selected value through client side javascript code and then able to get the hidden controls value during partial post back [Kind of laborious and dirty way]. Time being the problem was solved. If i come across better approach I'll update this post. If any of you have better solution please suggest.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment