This is a migrated thread and some comments may be shown as answers.

Failed to load viewstate in Rad window

4 Answers 187 Views
Window
This is a migrated thread and some comments may be shown as answers.
Lwin phyo
Top achievements
Rank 1
Lwin phyo asked on 11 Jul 2013, 09:58 AM
This is how I load rad window

<script type="text/javascript">
        function openRadWin(code, bookingdate, category) {
            radopen("MyPage.aspx", "RadWindow1");
        }
</script>
 
 <telerik:RadWindowManager ID="RadWindowManager1" runat="server" EnableShadow="true"
        VisibleStatusbar="false">
        <Windows>
            <telerik:RadWindow ID="RadWindow1" runat="server" ShowContentDuringLoad="false" Width="400px"
                Height="400px" Title="Telerik RadWindow" Behaviors="Default" >
            </telerik:RadWindow>
        </Windows>
</telerik:RadWindowManager>

The rad window pop-up and it show "MyPage.aspx" correctly . But , In "MyPage.aspx" , I have a RadGrid with "AllowFilteringByColumn="true" " . When I filter RadGrid , it shows me the error

Server Error in '/' Application.
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.

How can I fix it ?

4 Answers, 1 is accepted

Sort by
0
John Paul
Top achievements
Rank 1
answered on 14 Aug 2013, 12:16 AM
I have the same problem.

Any fix for this?
0
Marin Bratanov
Telerik team
answered on 14 Aug 2013, 10:30 AM
HI guys,

RadWindow does not modify the page inside, so this error, most likely, stems from something in the content page.

You can load that page directly in the browser and there should be no difference. This will let you debug it easily and see where the problem stems from.

Such an error, generally, means that some controls are not properly recreated upon postback, so you need to make sure that you recreate any dynamic controls properly (e.g. early enough, before viewstate loads, they must have the same IDs so that viewstate can be properly loaded for them, etc.). In case you are creating the grid dynamically I would advise that  you examine and follow this help article on the subject: http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
0
John Paul
Top achievements
Rank 1
answered on 15 Aug 2013, 05:42 PM

Thanks Marin for your quick response.

I am doing the entire setup of my grid inside RadGrid1_NeedDataSource. So, I am not sure where else should I be setting my controls. I don’t think I have to set it up in the Page_Init as the article describes.

Is there an easy way that I can view the controls and IDs that might be causing this problem?

0
Marin Bratanov
Telerik team
answered on 16 Aug 2013, 01:23 PM
Hi John,

Since the control tree has changed it is very hard to determine how exactly. What I can suggest is reducing the code and dynamically generated controls until you can find the culprit. In essence, following the approach from this blog post on reducing the complexity of the page so that the issue's origin can be tracked.


Regards,
Marin Bratanov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Window
Asked by
Lwin phyo
Top achievements
Rank 1
Answers by
John Paul
Top achievements
Rank 1
Marin Bratanov
Telerik team
Share this question
or