diff options
author | Ben Maurer <benm@mono-cvs.ximian.com> | 2003-11-23 01:01:19 +0300 |
---|---|---|
committer | Ben Maurer <benm@mono-cvs.ximian.com> | 2003-11-23 01:01:19 +0300 |
commit | d2f9b77b7aede829376dd2bdbe1aab3e4ac5b870 (patch) | |
tree | 7f4c2cda1d360798381dab0ca0955d36878ff1ec | |
parent | 2fb22ed80803c5a02b4345c7fa64153172ab7a2a (diff) |
2003-11-22 Ben Maurer <bmaurer@users.sourceforge.net>
* Calendar.cs (SaveViewState):
- We were allocating a 11 item array, we only used 10 items,
so only allocate 10.
- We only need to save the selected dates if there are any.
* DataGrid.cs (SaveViewState):
* DataGridColumn.cs (SaveViewState):
* DataGridColumnCollection.cs (SaveViewState):
- Only return the array if there is anything in it
* Style.cs (SaveViewState):
- Only save the bits if there were changes.
* WebControl.cs (SaveViewState), (LoadViewState):
- Don't save Enabled into the viewstate here, we already
do it in the property. This just caused *EVERY* control
to have a non-null state, taking up lots of extra room
in the ViewState.
- The style will always be created with this control's
viewstate, so the style will always return null for the
viewstate. As such, we do not need to store it. We can
also reduce the triplet to a pair because of this.
svn path=/trunk/mcs/; revision=20342
7 files changed, 63 insertions, 24 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs index eadac162220..bc6c67841ef 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Calendar.cs @@ -779,9 +779,11 @@ namespace System.Web.UI.WebControls }
protected override object SaveViewState()
- {
- ViewState["_CalendarSelectedDates"] = (SelectedDates.Count > 0 ? selectedDates.GetDateList () : null);
- object[] states = new object[11];
+ { + if (SelectedDates.Count > 0)
+ ViewState["_CalendarSelectedDates"] = selectedDates.GetDateList (); +
+ object[] states = new object [10];
states[0] = base.SaveViewState();
states[1] = (dayHeaderStyle == null ? null : dayHeaderStyle.SaveViewState());
states[2] = (dayStyle == null ? null : dayStyle.SaveViewState());
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog index 782b586fc3c..e2c9de37158 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog +++ b/mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog @@ -1,7 +1,29 @@ +2003-11-22 Ben Maurer <bmaurer@users.sourceforge.net> + + * Calendar.cs (SaveViewState): + - We were allocating a 11 item array, we only used 10 items, + so only allocate 10. + - We only need to save the selected dates if there are any. + * DataGrid.cs (SaveViewState): + * DataGridColumn.cs (SaveViewState): + * DataGridColumnCollection.cs (SaveViewState): + - Only return the array if there is anything in it + * Style.cs (SaveViewState): + - Only save the bits if there were changes. + * WebControl.cs (SaveViewState), (LoadViewState): + - Don't save Enabled into the viewstate here, we already + do it in the property. This just caused *EVERY* control + to have a non-null state, taking up lots of extra room + in the ViewState. + - The style will always be created with this control's + viewstate, so the style will always return null for the + viewstate. As such, we do not need to store it. We can + also reduce the triplet to a pair because of this. + 2003-11-22 Jackson Harper <jackson@ximian.com> * ValidationSummary.cs: Fix number of messages and message array computation. - + 2003-11-21 Andreas Nahr <ClassDevelopment@A-SoftTech.com> * Xml.cs: Corrected attribute diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs index e1bb56d4e9c..219bd78a710 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGrid.cs @@ -696,7 +696,12 @@ namespace System.Web.UI.WebControls states[6] = (alternatingItemStyle == null ? null : alternatingItemStyle.SaveViewState()); states[7] = (selectedItemStyle == null ? null : selectedItemStyle.SaveViewState()); states[8] = (editItemStyle == null ? null : editItemStyle.SaveViewState()); - return states; + + for (int i = 0; i < states.Length; i++) { + if (states [i] != null) + return states; + } + return null; } protected override void TrackViewState() diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs index 007d00cdb9f..275867644bb 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumn.cs @@ -360,7 +360,12 @@ namespace System.Web.UI.WebControls states[1] = (footerStyle == null ? null : footerStyle.SaveViewState()); states[2] = (headerStyle == null ? null : headerStyle.SaveViewState()); states[3] = (itemStyle == null ? null : itemStyle.SaveViewState()); - return states; + + for (int i = 0; i < states.Length; i++) { + if (states [i] != null) + return states; + } + return null; } protected virtual void LoadViewState(object savedState) diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs index a2702f665d0..c247dcde350 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/DataGridColumnCollection.cs @@ -160,10 +160,18 @@ namespace System.Web.UI.WebControls if (columns.Count == 0)
return null;
- ArrayList retVal = new ArrayList (columns.Count);
- foreach (IStateManager current in columns)
- retVal.Add (current.SaveViewState ());
+ ArrayList retVal = new ArrayList (columns.Count); + bool found = false;
+ foreach (IStateManager current in columns) { + object o = current.SaveViewState ();
+ retVal.Add (o); + if (o != null) + found = true; + }
+ if (!found) + return null; + return retVal;
}
diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs index 436a86902c2..67819dc3cd7 100644 --- a/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/Style.cs @@ -451,7 +451,7 @@ namespace System.Web.UI.WebControls protected internal virtual object SaveViewState () { if (viewState != null) { - if (marked) + if (marked && IsSet (MARKED)) ViewState [selectionBitString] = selectionBits; if (selfStateBag) diff --git a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs index 67cc1063d50..eed3bb0a6a1 100755 --- a/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs +++ b/mcs/class/System.Web/System.Web.UI.WebControls/WebControl.cs @@ -426,18 +426,14 @@ namespace System.Web.UI.WebControls if (savedState == null) return; - Triplet saved = (Triplet) savedState; + Pair saved = (Pair) savedState; base.LoadViewState (saved.First); - if (saved.Second != null || - ViewState [System.Web.UI.WebControls.Style.selectionBitString] != null) - ControlStyle.LoadViewState (saved.Second); + + if (ControlStyleCreated || ViewState [System.Web.UI.WebControls.Style.selectionBitString] != null) + ControlStyle.LoadViewState (null); if (attributeState != null) - attributeState.LoadViewState (saved.Third); - - object e = ViewState ["Enabled"]; - if (e != null) - enabled = (bool) e; + attributeState.LoadViewState (saved.Second); } protected override void Render(HtmlTextWriter writer) @@ -454,17 +450,18 @@ namespace System.Web.UI.WebControls protected override object SaveViewState() { - object controlView = null; if (ControlStyleCreated) - controlView = ControlStyle.SaveViewState (); - - ViewState ["Enabled"] = enabled; + ControlStyle.SaveViewState (); + object baseView = base.SaveViewState (); object attrView = null; if (attributeState != null) attrView = attributeState.SaveViewState (); + + if (baseView == null && attrView == null) + return null; - return new Triplet (baseView, controlView, attrView); + return new Pair (baseView, attrView); } protected override void TrackViewState() |