Setting ViewStateEnabled=False at page level doesn't stop ViewState on RadMultiPage?

2 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 28 Sep 2011 Link to this post

    Hi Telerik,

    I am confused. I was under the impression that if I had the following page declaration:

    <%@ Page Title="Home Page" MasterPageFile="~/Views/Shared/WebForm.master" EnableViewState="False" Language="C#" AutoEventWireup="True" CodeBehind="Dashboard.aspx.cs" Inherits="CableSolve.Web.Dashboard.Dashboard"%>

    that ViewState for controls on the page, at least when not explicitly stated, would be disabled. Is this an erroneous assumption? If so, what does setting ViewState at the Page level do?

    If my assumption is not erroneous -- I am seeing the following behavior:

    • Inside of an event for RadTabStrip I set my RadTabStrip's selected index to 1 and my MultiPage.PageViews[1].Selected = true.
    • Instead of calling Update on an UpdatePanel to visually show the changes to the MultiPage, I register a StartupScript.
    • Now, client-side, I set the MultiPage's PageView. This now causes the PageView to visually change for the user.
    • I then refresh the page. In my control regeneration code I see that my TabStrip and MultiPage are both set with indices of 1.
    • The RadTabStrip shows the tab at index 1 selected, but the MultiPage shows the PageView at index 0.

    If I call Update on an UpdatePanel, instead of doing the changes client-side, everything works great.
    If I disable ViewState on the MultiPage, everything works great.

    This was just a surprise to me because I thought that the ViewState was implicitly disabled for the control. I hadn't set the ViewState one way or the other, and I know it defaults to true, but I thought the Page would override this value.

    /// <summary>
    /// Performs one tick of a timer on the chart.
    /// Ticks based on time for testability and to prevent
    /// weird cases when skipping the clock time forward.
    /// </summary>
    public void DoTimerCycleTick(object sender, TimerEventArgs eventArgs)
        GlobalSettings globalSettings = StateManager.GetStates<GlobalSettings>();
        if( globalSettings.CycleEnabled )
            if (!Equals(DateTime.Now.CompareTo(globalSettings.TimeLastCycled.AddMinutes(globalSettings.CycleInterval)), -1)) //CompareTo returns -1 when time is earlier than.
                int oldIndex = SelectedIndex;
                int newIndex = (oldIndex + 1) != Tabs.Count ? (oldIndex + 1) : 0;
                SelectedIndex = newIndex;
                LayoutManager.Instance.MultiPage.PageViews[newIndex].Selected = true;
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "KEY", string.Format("OnServerTabSelected({0});", newIndex), true);
                globalSettings.TimeLastCycled = DateTime.Now;

    var showLoadingPanel = true;
    function OnServerTabSelected(newIndex) {
        var oldID = $find(multiPageID).get_selectedPageView().get_id();
        var newID = $find(multiPageID).get_pageViews().getPageView(newIndex).get_id();
        if ($telerik.$("#" + oldID).is(":visible")) {
            $telerik.$("#" + oldID).fadeOut(1000, function () {
                $telerik.$("#" + newID).fadeIn(1000, function () {
                    showLoadingPanel = true;
            showLoadingPanel = false;

  2. Dimitar Terziev
    Dimitar Terziev avatar
    1268 posts

    Posted 03 Oct 2011 Link to this post

    Hello Sean,

    In general when you disable the view state on the page it should be disable for all controls in it. The experienced behavior that you have described seems like a bug with the RadMultiPage. In order to ensure that this is a bug, please open a support ticket and provide a runnable sample page so I could examine the problem locally.

    Dimitar Terziev
    the Telerik team
    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 their blog feed now
Back to Top