فهرست منبع

2005-04-07 Lluis Sanchez Gual <[email protected]>

	* TemplateControl.cs:
	* Page.cs: Moved Eval and XPath from Page
	to TemplateControl.
	* StateManagedCollection.cs: Avoid saving null state.


svn path=/trunk/mcs/; revision=42645
Lluis Sanchez 21 سال پیش
والد
کامیت
bbdbfabccf

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

@@ -1,3 +1,10 @@
+2005-04-07  Lluis Sanchez Gual <[email protected]>
+
+	* TemplateControl.cs:
+	* Page.cs: Moved Eval and XPath from Page
+	to TemplateControl.
+	* StateManagedCollection.cs: Avoid saving null state.
+
 2005-04-01  Lluis Sanchez Gual <[email protected]>
 
 	* DataSourceView.cs: Rethrow exceptions not handled by operation

+ 0 - 52
mcs/class/System.Web/System.Web.UI/Page.cs

@@ -1277,58 +1277,6 @@ public class Page : TemplateControl, IHttpHandler
 		_form = form;
 	}
 	
-	Stack dataItemCtx;
-	
-	internal void PushDataItemContext (object o)
-	{
-		if (dataItemCtx == null)
-			dataItemCtx = new Stack ();
-		
-		dataItemCtx.Push (o);
-	}
-	
-	internal void PopDataItemContext ()
-	{
-		if (dataItemCtx == null)
-			throw new InvalidOperationException ();
-		
-		dataItemCtx.Pop ();
-	}
-	
-	internal object CurrentDataItem {
-		get {
-			if (dataItemCtx == null)
-				throw new InvalidOperationException ("No data item");
-			
-			return dataItemCtx.Peek ();
-		}
-	}
-	
-	protected object Eval (string expression)
-	{
-		return DataBinder.Eval (CurrentDataItem, expression);
-	}
-	
-	protected object Eval (string expression, string format)
-	{
-		return DataBinder.Eval (CurrentDataItem, expression, format);
-	}
-	
-	protected object XPath (string xpathexpression)
-	{
-		return XPathBinder.Eval (CurrentDataItem, xpathexpression);
-	}
-	
-	protected object XPath (string xpathexpression, string format)
-	{
-		return XPathBinder.Eval (CurrentDataItem, xpathexpression, format);
-	}
-	
-	protected IEnumerable XPathSelect (string xpathexpression)
-	{
-		return XPathBinder.Select (CurrentDataItem, xpathexpression);
-	}
-	
     [BrowsableAttribute (false)]
     [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
 	public Page PreviousPage {

+ 6 - 1
mcs/class/System.Web/System.Web.UI/StateManagedCollection.cs

@@ -78,6 +78,8 @@ namespace System.Web.UI {
 		#region IStateManager
 		void IStateManager.LoadViewState (object savedState)
 		{
+			if (savedState == null) return;
+
 			int pos = -1;
 			foreach (Pair p in (ArrayList)savedState) {
 				pos ++;
@@ -108,6 +110,7 @@ namespace System.Web.UI {
 		{
 			ArrayList saved = new ArrayList ();
 			Type [] knownTypes = GetKnownTypes ();
+			bool allNull = true;
 			
 			foreach (IStateManager itm in items) {
 				object state = itm.SaveViewState ();
@@ -130,9 +133,11 @@ namespace System.Web.UI {
 					p.Second = t;
 				
 				saved.Add (p);
+				allNull = false;
 			}
 			
-			return saved;
+			if (allNull) return null;
+			else return saved;
 		}
 		
 		void IStateManager.TrackViewState ()

+ 55 - 0
mcs/class/System.Web/System.Web.UI/TemplateControl.cs

@@ -260,5 +260,60 @@ namespace System.Web.UI {
 			}
 		}
 
+#if NET_2_0
+
+	Stack dataItemCtx;
+	
+	internal void PushDataItemContext (object o)
+	{
+		if (dataItemCtx == null)
+			dataItemCtx = new Stack ();
+		
+		dataItemCtx.Push (o);
+	}
+	
+	internal void PopDataItemContext ()
+	{
+		if (dataItemCtx == null)
+			throw new InvalidOperationException ();
+		
+		dataItemCtx.Pop ();
+	}
+	
+	internal object CurrentDataItem {
+		get {
+			if (dataItemCtx == null)
+				throw new InvalidOperationException ("No data item");
+			
+			return dataItemCtx.Peek ();
+		}
+	}
+	
+	protected object Eval (string expression)
+	{
+		return DataBinder.Eval (CurrentDataItem, expression);
+	}
+	
+	protected object Eval (string expression, string format)
+	{
+		return DataBinder.Eval (CurrentDataItem, expression, format);
+	}
+	
+	protected object XPath (string xpathexpression)
+	{
+		return XPathBinder.Eval (CurrentDataItem, xpathexpression);
+	}
+	
+	protected object XPath (string xpathexpression, string format)
+	{
+		return XPathBinder.Eval (CurrentDataItem, xpathexpression, format);
+	}
+	
+	protected IEnumerable XPathSelect (string xpathexpression)
+	{
+		return XPathBinder.Select (CurrentDataItem, xpathexpression);
+	}
+#endif
+
 	}
 }