Odd viewstate error

6 posts, 0 answers
  1. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 02 Apr 2008 Link to this post

    I'm running into an odd viewstate error. The official error I'm getting is "The state information is invalid for this page and might be corrupted."

    Here's how to reproduce. Create two pages. Mine both used a master page but I don't think that matters in this case. The first page simply needs a link to the second page. On the second page, add a RadGrid and RadAjaxManager like so:

        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" 
            GridLines="Horizontal" 
            OnNeedDataSource="RadGrid1_NeedDataSource" 
            AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" > 
            <MasterTableView DataKeyNames="Key" EditMode="InPlace" CommandItemDisplay="Top"
                <Columns> 
                    <telerik:GridEditCommandColumn> 
                    </telerik:GridEditCommandColumn> 
                     
                    <telerik:GridBoundColumn DataField="Name"
                    </telerik:GridBoundColumn> 
                </Columns> 
            </MasterTableView> 
        </telerik:RadGrid> 
         
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
            <AjaxSettings> 
                <telerik:AjaxSetting AjaxControlID="RadGrid1"
                    <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="GridLoadingPanel" /> 
                    </UpdatedControls> 
                </telerik:AjaxSetting> 
            </AjaxSettings> 
        </telerik:RadAjaxManager> 
         
        <telerik:RadAjaxLoadingPanel ID="GridLoadingPanel" runat="server" Transparency="30"
            <img alt="Loading..." 
                style="margin-top: 100px; border-width: 0px;"  
                src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' /> 
        </telerik:RadAjaxLoadingPanel> 

    In my case, the grid's data source in the NeedDataSource event is a custom collection of "Foo" items which look like:

        public class Foo 
        { 
            #region public string Key 
            private string _key; 
            public string Key 
            { 
                get { return _key; } 
                set { _key = value; } 
            } 
            #endregion 
            #region public string Name 
            private string _name; 
            public string Name 
            { 
                get { return _name; } 
                set { _name = value; } 
            } 
            #endregion 
        } 
     


    To reproduce the problem do the following:
    1. Go to your first page and use your link to navigate to the second page.
    2. Click the "Add" button on the grid.
    3. Hit the (evil) Back button on your browser.
    4. Hit the (more evil) Forward button on your browser.
    5. Click the "Add" button again.

    If I disable ViewState MAC checking, I get an Invalid ViewState error.

    Is there a fix for this other than user education?
  2. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 03 Apr 2008 Link to this post

    Hi Thomas,

    Is this error by any chance caused only on Firefox? If this is the case can you add the following to the Page_Load of the offending page:

    protected void Page_Load(object sender, EventArgs e)
    {
       if (Request.Browser.MSDomVersion.Major == 0) // Non IE Browser?)
       {
           Response.Cache.SetNoStore(); // No client side cashing for non IE browsers
       }
    }

    If this is happening on IE as well, please make sure that the GridEditCommandColumn has ButtonType different than ImageButton.
    If the above does not help, please elaborate how do you redirect to the other page - do you use Response.Redirect? What type of control makes the redirect? Any additional information would be highly appreciated.

    Sincerely yours,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Thomas
    Thomas avatar
    143 posts
    Member since:
    Feb 2007

    Posted 03 Apr 2008 Link to this post

    I have confirmed that the problem only occurs in FF. However, isn't disabling all client side caching a bit draconian? Isn't that like putting out a match with a fire engine hose?

    (Btw, the redirect can be a simple href tag).
  5. Steve
    Admin
    Steve avatar
    10941 posts

    Posted 04 Apr 2008 Link to this post

    Hello Thomas,

    We've found this solution somewhere in mozillazine if I recall correctly, where someone else has encountered this problem in other scenarios. There was a discussion about that but unfortunately there is no other "workaround" for the time being as this is entirely mozilla specific behavior that we do not have control over.
    Can you share what is bothering you, when having this setting enabled?

    Kind regards,
    Steve
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. DonKitchen
    DonKitchen avatar
    92 posts
    Member since:
    Jul 2007

    Posted 28 May 2009 Link to this post

    Steve (or other Telerik staff),

    I'm curious why you suggest this for IE:

    If this is happening on IE as well, please make sure that the GridEditCommandColumn has ButtonType different than ImageButton.

  7. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 29 May 2009 Link to this post

    Hello Don,

    This is rather an old thread and most probably there was some kind of issue with the Prometheus (Beta) version of RadControls for ASP.NET AJAX in this case. I suggest you migrate to the latest release 2009.1.527 of RadControls to see whether the problem disappears.

    You may also test the same case by removing the RadAjaxManager from the page and using MS UpdatePanel to ajaxify the grid or plain postbacks to compare the results. This can shed some additional light on whether the issue is related to the ASP.NET AJAX framework or particularly to some of our controls.

    Kind regards,
    Sebastian
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017