by Raju Maharjan
4. August 2011 15:30
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.
In the context of the data controls, this happens when a control that isn't registered for event validation causes a postback, but surely that can't be the case.. right?
The reason this happens is because we rebind the data control in Page_Load every time which means that we will lose all of the posted data and viewstate. As a result, the ID of the Control is different and when the event is validated there will be no matching unique id and hence event validation will fail. We are acutally raising an event for a button that is no longer in the control tree.
You can work around this by wrapping that code in if (!IsPostBack). This is a good proof of why you should use DataSource controls.
by Raju Maharjan
27. November 2010 14:57
Using JSON in your ASP.NET application seems hard until you try it. It will get very convenient as you start using it. It is pretty easy to use an UpdatePanel than JSON. But JSON is easy enough that you may decide to use it over the UpdatePanel under certain circumstances.
The obvious problem with the UpdatePanel is that all of the form data gets posted to the server and all of the server code runs during every update. While there are ways of detecting that the UpdatePanel is causing the postback and thereby limiting the amount of code that runs on the server, you are still left with a full submit of the client form elements to contend with. On a large form, and a form with a lot of view state information, this could be a huge consideration.
On the other hand, JSON only sends the data that is needed for the WebService function it is calling and only returns the data that the WebService function returns. So you end up sending less data, executing less code on the server, and returning less code from the server. This can significantly increase the performance of your application as well as increase the scalability of your application.
However, it will take a lot more work to JSON-enable in cases like GridView, treeview etc. In these case cost of the development outweighs the performance gains of JSON and more likely to stay with the UpdatePanel. So we have options for using the best one in the most suitable cases.