To solve this problem,

<pages enableEventValidation="false"/> in Web.Config or,
<%@ Page EnableEventValidation="false" %> in a page attribute

By doing this, we are giving a way to hacker to intrude by disabling the
event validation.

This can be prevented by use of RegisterForEventValidation methods of
ClientScriptManager class

We need to register the server control ID with the all the possible values
that can be posted by JavaScript by that control in Render Event of the page
using

ClientScript.RegisterForEventValidation()

Check out this for the relavant article
http://www.codedigest.com/Articles/ASPNET/221_Using_JavaScript_Effectively_in_ASPNet_20_%e2%80%93_PART_2.aspx


On Wed, Sep 9, 2009 at 11:24 PM, Raghupathi Kamuni <[email protected]>wrote:

> ViewState  and Dynamic Control
> http://geekswithblogs.net/FrostRed/archive/2007/02/17/106547.aspx
>
> http://weblogs.asp.net/alessandro/archive/2008/01/04/failed-to-load-viewstate-typical-problem-with-an-obvious-solution.aspx
>
>
>
> On Wed, Sep 9, 2009 at 11:01 PM, Ana <[email protected]> wrote:
>
>>
>> Hi,
>>
>> In my page I have a Gridview and a FormView. For each row in the
>> GridView, there's a linkButton *Details* that shows the FormView with
>> the information about the selected record in the GridView.
>> In the FormView, users are able to edit and delete records. However,
>> every time I cancel the editing of a record and try to see the
>> formview for this record (clicking in *Details* on the GridView), I
>> have the following error message:
>>
>> --
>> Failed to load viewstate.  The control tree into which viewstate is
>> being loaded must match the control tree that was used to save
>> viewstate during the previous request.  For example, when adding
>> controls dynamically, the controls added during a post-back must match
>> the type and position of the controls added during the initial
>> request.
>> --
>>
>> What is happening here? Why this error message in being fired?
>>
>> Thanks in advance,
>>
>> Ana
>
>
>

Reply via email to