Failed to load viewstate in Rad window

5 posts, 0 answers
  1. Lwin phyo
    Lwin phyo avatar
    2 posts
    Member since:
    Jun 2013

    Posted 11 Jul 2013 Link to this post

    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 ?
  2. John Paul
    John Paul avatar
    2 posts
    Member since:
    Jan 2008

    Posted 13 Aug 2013 Link to this post

    I have the same problem.

    Any fix for this?
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 14 Aug 2013 Link to this post

    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.
  5. John Paul
    John Paul avatar
    2 posts
    Member since:
    Jan 2008

    Posted 15 Aug 2013 Link to this post

    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?

  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 16 Aug 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017