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:
In my case, the grid's data source in the NeedDataSource event is a custom collection of "Foo" items which look like:
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?
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?