Преглед на файлове

2008-10-14 Marek Habersack <[email protected]>

	* Control.cs: SaveViewStateRecursive must return view state even
	if EnableViewState is false. This is apparently what .NET does, as
	some commercial ASP.NET controls take advantage of that via
	reflection.

2008-10-14  Marek Habersack  <[email protected]>

	* CompositeDataBoundControl.cs: renamed the itemcount ViewState
	item from "_ItemCount" to "_!ItemCount" for .NET
	compatibility. This item is accessed and used by some commercial
	ASP.NET controls.

	* DataBoundControl.cs: OnPagePreLoad must force databinding also
	when the request is not a postback.

svn path=/trunk/mcs/; revision=115766
Marek Habersack преди 17 години
родител
ревизия
071470bef4

+ 10 - 0
mcs/class/System.Web/System.Web.UI.WebControls/ChangeLog

@@ -1,3 +1,13 @@
+2008-10-14  Marek Habersack  <[email protected]>
+
+	* CompositeDataBoundControl.cs: renamed the itemcount ViewState
+	item from "_ItemCount" to "_!ItemCount" for .NET
+	compatibility. This item is accessed and used by some commercial
+	ASP.NET controls.
+
+	* DataBoundControl.cs: OnPagePreLoad must force databinding also
+	when the request is not a postback.
+
 2008-10-13  Marek Habersack  <[email protected]>
 
 	* Table.cs, TableRowCollection.cs, TableRow.cs: render table

+ 3 - 2
mcs/class/System.Web/System.Web.UI.WebControls/CompositeDataBoundControl.cs

@@ -53,7 +53,7 @@ namespace System.Web.UI.WebControls
 		{
 			Controls.Clear ();
 
-			object itemCount = ViewState ["_ItemCount"];
+			object itemCount = ViewState ["_!ItemCount"];
 			if (itemCount != null) {
 				object [] data = new object [(int) itemCount];
 				CreateChildControls (data, false);
@@ -64,8 +64,9 @@ namespace System.Web.UI.WebControls
 		
 		protected internal override void PerformDataBinding (IEnumerable data)
 		{
+			base.PerformDataBinding (data);
 			Controls.Clear ();
-			ViewState ["_ItemCount"] = CreateChildControls (data, true);
+			ViewState ["_!ItemCount"] = CreateChildControls (data, true);
 		}
 		
 		protected abstract int CreateChildControls (IEnumerable dataSource, bool dataBinding);

+ 15 - 4
mcs/class/System.Web/System.Web.UI.WebControls/DataBoundControl.cs

@@ -119,7 +119,15 @@ namespace System.Web.UI.WebControls {
 		// MSDN: The OnPagePreLoad method is overridden by the DataBoundControl class 
 		// to set the BaseDataBoundControl.RequiresDataBinding property to true in 
 		// cases where the HTTP request is a postback and view state is enabled but 
-		// the data-bound control has not yet been bound. 
+		// the data-bound control has not yet been bound.
+		//
+		// LAMESPEC: RequiresDataBinding is also set when http request is NOT a postback -
+		// no matter whether view state is enabled. The correct description should be:
+		//
+		// The OnPagePreLoad method is override by the DataBoundControl class 
+		// to set the BaseDataBoundControl.RequiresDataBinding property to true in 
+		// cases where the HTTP request is not a postback or it is a postback and view state
+		// is enabled but the data-bound control has not yet been bound.
 		protected override void OnPagePreLoad (object sender, EventArgs e)
 		{
 			base.OnPagePreLoad (sender, e);
@@ -127,12 +135,15 @@ namespace System.Web.UI.WebControls {
 			Initialize ();
 		}
 
-		private void Initialize ()
+		void Initialize ()
 		{
 			Page page = Page;
-			if (page != null)
-				if (!IsDataBound && !page.IsPostBack && IsViewStateEnabled)
+			if (page != null) {
+				// LAMESPEC: see the comment above OnPagePreLoad
+				if (!page.IsPostBack || (!IsDataBound && IsViewStateEnabled))
 					RequiresDataBinding = true;
+			}
+			
 		}
 		
 		void UpdateViewData ()

+ 7 - 0
mcs/class/System.Web/System.Web.UI/ChangeLog

@@ -1,3 +1,10 @@
+2008-10-14  Marek Habersack  <[email protected]>
+
+	* Control.cs: SaveViewStateRecursive must return view state even
+	if EnableViewState is false. This is apparently what .NET does, as
+	some commercial ASP.NET controls take advantage of that via
+	reflection.
+
 2008-10-08  Marek Habersack  <[email protected]>
 
 	* DataBinder.cs: in Eval expression needs to be trimmed before

+ 1 - 4
mcs/class/System.Web/System.Web.UI/Control.cs

@@ -1571,9 +1571,6 @@ namespace System.Web.UI
 
 		internal object SaveViewStateRecursive ()
 		{
-			if (!EnableViewState)
-				return null;
-
 			TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
 #if MONO_TRACE
 			string type_name = null;
@@ -1637,7 +1634,7 @@ namespace System.Web.UI
 
 		internal void LoadViewStateRecursive (object savedState)
 		{
-			if (!EnableViewState || savedState == null)
+			if (savedState == null)
 				return;
 
 #if MONO_TRACE