Hi Telerik,
I am confused. I was under the impression that if I had the following page declaration:
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:
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.
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;
}
}
StateManager.SaveGlobalSettings(globalSettings);
}
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
;
$find(multiPageID).set_selectedIndex(newIndex);
});
});
showLoadingPanel =
false
;
FixSplitter($find(rightPaneID));
return
;
}
}