2005-01-28 Lluis Sanchez Gual <lluis@novell.com>
authorLluis Sanchez <lluis@novell.com>
Sat, 29 Jan 2005 00:03:46 +0000 (00:03 -0000)
committerLluis Sanchez <lluis@novell.com>
Sat, 29 Jan 2005 00:03:46 +0000 (00:03 -0000)
* ParseChildrenAttribute.cs: Added 2.0 property.
* Pair.cs, Triplet.cs: Make classes serializable and sealed in 2.0.
* Page.cs: Added support for control state.
* TemplateBuilder.cs: ContainerType should be internal.
* Control.cs: Added some new 2.0 methods.

svn path=/trunk/mcs/; revision=39730

mcs/class/System.Web/System.Web.UI/ChangeLog
mcs/class/System.Web/System.Web.UI/Control.cs
mcs/class/System.Web/System.Web.UI/Page.cs
mcs/class/System.Web/System.Web.UI/Pair.cs
mcs/class/System.Web/System.Web.UI/ParseChildrenAttribute.cs
mcs/class/System.Web/System.Web.UI/TemplateBuilder.cs
mcs/class/System.Web/System.Web.UI/Triplet.cs

index 06e72259cdbf547c0f1febbd87b0eba0625d9bf5..899a84591c4da62a1a824daa5d4e1f91d38fa792 100644 (file)
@@ -1,3 +1,11 @@
+2005-01-28  Lluis Sanchez Gual <lluis@novell.com>
+
+       * ParseChildrenAttribute.cs: Added 2.0 property.
+       * Pair.cs, Triplet.cs: Make classes serializable and sealed in 2.0.
+       * Page.cs: Added support for control state.
+       * TemplateBuilder.cs: ContainerType should be internal.
+       * Control.cs: Added some new 2.0 methods.
+
 2005-01-21  Lluis Sanchez Gual <lluis@novell.com>
 
        * PageParser.cs: Read the MasterPageFile attribute.
index 819e58796018caae2b991164ff53617d18c75b9c..d9aa1267257cda28a3eb06531b81536b6014b7a3 100644 (file)
@@ -1080,8 +1080,17 @@ namespace System.Web.UI
                public virtual void Focus()\r
                {\r
                        throw new NotImplementedException();\r
-               }\r
-
+               }
+               
+               protected internal virtual void LoadControlState (object state)
+               {
+               }
+               
+               protected internal virtual object SaveControlState ()
+               {
+                       return null;
+               }
+               
 #endif\r
         }\r
 }\r
index 7204d9133c39f3229b7beb7f623e658c684f1728..7010cadd01d7c87df45eae8599cc53b8250c7ec4 100755 (executable)
@@ -92,6 +92,8 @@ public class Page : TemplateControl, IHttpHandler
        
        MasterPage masterPage;
        string masterPageFile;
+       
+       ArrayList requireStateControls;
 #endif
 
        #region Constructor
@@ -501,13 +503,21 @@ public class Page : TemplateControl, IHttpHandler
                cache.SetExpires (_context.Timestamp.AddSeconds (duration));
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public bool IsClientScriptBlockRegistered (string key)
        {
                return scriptManager.IsClientScriptBlockRegistered (key);
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public bool IsStartupScriptRegistered (string key)
        {
                return scriptManager.IsStartupScriptRegistered (key);
@@ -806,19 +816,31 @@ public class Page : TemplateControl, IHttpHandler
                sourceControl.RaisePostBackEvent (eventArgument);
        }
        
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public void RegisterArrayDeclaration (string arrayName, string arrayValue)
        {
                scriptManager.RegisterArrayDeclaration (arrayName, arrayValue);
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public virtual void RegisterClientScriptBlock (string key, string script)
        {
                scriptManager.RegisterClientScriptBlock (key, script);
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public virtual void RegisterHiddenField (string hiddenFieldName, string hiddenFieldInitialValue)
        {
                scriptManager.RegisterHiddenField (hiddenFieldName, hiddenFieldInitialValue);
@@ -830,7 +852,11 @@ public class Page : TemplateControl, IHttpHandler
                throw new NotImplementedException ();
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public void RegisterOnSubmitStatement (string key, string script)
        {
                scriptManager.RegisterOnSubmitStatement (key, script);
@@ -851,7 +877,11 @@ public class Page : TemplateControl, IHttpHandler
                requiresRaiseEvent = control;
        }
 
+#if NET_2_0
+       [Obsolete]
+#else
        [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
        public virtual void RegisterStartupScript (string key, string script)
        {
                scriptManager.RegisterStartupScript (key, script);
@@ -893,9 +923,16 @@ public class Page : TemplateControl, IHttpHandler
        {
                object sState = LoadPageStateFromPersistenceMedium ();
                if (sState != null) {
+#if NET_2_0
+                       Triplet data = (Triplet) sState;
+                       LoadViewStateRecursive (data.First);
+                       _requiresPostBack = data.Second as ArrayList;
+                       LoadPageControlState (data.Third);
+#else
                        Pair pair = (Pair) sState;
                        LoadViewStateRecursive (pair.First);
                        _requiresPostBack = pair.Second as ArrayList;
+#endif
                }
        }
 
@@ -904,15 +941,29 @@ public class Page : TemplateControl, IHttpHandler
                if (!handleViewState)
                        return;
 
+               object viewState = SaveViewStateRecursive ();
+               object reqPostback = (_requiresPostBack != null && _requiresPostBack.Count > 0) ? _requiresPostBack : null;
+
+#if NET_2_0
+               Triplet triplet = new Triplet ();
+               triplet.First = viewState;
+               triplet.Second = reqPostback;
+               triplet.Third = SavePageControlState ();
+
+               if (triplet.First == null && triplet.Second == null && triplet.Third == null)
+                       triplet = null;
+                       
+               SavePageStateToPersistenceMedium (triplet);
+#else
                Pair pair = new Pair ();
-               pair.First = SaveViewStateRecursive ();
-               if (_requiresPostBack != null && _requiresPostBack.Count > 0)
-                       pair.Second = _requiresPostBack;
+               pair.First = viewState;
+               pair.Second = reqPostback;
 
                if (pair.First == null && pair.Second == null)
                        pair = null;
-
+                       
                SavePageStateToPersistenceMedium (pair);
+#endif
        }
 
        public virtual void Validate ()
@@ -1068,6 +1119,37 @@ public class Page : TemplateControl, IHttpHandler
                        return masterPage;
                }
        }
+       
+       public void RegisterRequiresControlState (Control control)
+       {
+               if (requireStateControls == null) requireStateControls = new ArrayList ();
+               requireStateControls.Add (control);
+       }
+       
+       object SavePageControlState ()
+       {
+               if (requireStateControls == null) return null;
+               object[] state = new object [requireStateControls.Count];
+               
+               bool allNull = true;
+               for (int n=0; n<state.Length; n++) {
+                       state [n] = ((Control) requireStateControls [n]).SaveControlState ();
+                       if (state [n] != null) allNull = false;
+               }
+               if (allNull) return null;
+               else return state;
+       }
+       
+       void LoadPageControlState (object data)
+       {
+               if (requireStateControls == null) return;
+
+               object[] state = (object[]) data;
+               for (int n=0; n<state.Length && n < requireStateControls.Count; n++) {
+                       Control ctl = (Control) requireStateControls [n];
+                       ctl.LoadControlState (state [n]);
+               }
+       }
 
        #endif
 }
index b5107377c88cb295e1cbf4c06a7c00778f5fcae0..0a6192891490e2c7bc3c1b6d29802760c2fbca6c 100644 (file)
@@ -39,6 +39,10 @@ using System.Collections.Specialized;
 \r
 namespace System.Web.UI\r
 {\r
+#if NET_2_0\r
+       [Serializable]\r
+       sealed\r
+#endif\r
        public class Pair\r
        {\r
                public object First;\r
index 238183df013728bb1c4543994efaf41827491650..f28fbe23f7c725de512e0a738654aaff20f002c6 100755 (executable)
@@ -39,6 +39,10 @@ namespace System.Web.UI {
                bool childrenAsProperties;
                string defaultProperty;
                public static readonly ParseChildrenAttribute Default = new ParseChildrenAttribute ();
+               
+#if NET_2_0
+               Type childType;
+#endif
 
                // LAMESPEC
                public ParseChildrenAttribute ()
@@ -74,6 +78,13 @@ namespace System.Web.UI {
                        set { defaultProperty = value; }
                }
 
+#if NET_2_0
+               public Type ChildControlType {
+                       get { return childType; }
+                       set { childType = value; }
+               }
+#endif
+
                public override bool Equals (object obj)
                {
                        if (!(obj is ParseChildrenAttribute))
index ea64fe9e1ed2f71365f5af5cfd5e227f9858a5f8..f779c5db09c4e8dfdac5ea7f041be1c58a55f793 100644 (file)
@@ -56,7 +56,7 @@ namespace System.Web.UI
                        set { text = value; }
                }
                
-               public Type ContainerType {
+               internal Type ContainerType {
                        get { return containerAttribute != null ? containerAttribute.ContainerType : null; }
                }
 
index b8cbf6569ae81a01772cc13c4d46cec7ccaffc02..c3d3046adb5b98ca5cbb3744a8723a3be9ba513c 100755 (executable)
@@ -31,6 +31,10 @@ using System;
 
 namespace System.Web.UI {
 
+#if NET_2_0
+       [Serializable]
+       sealed
+#endif
        public class Triplet
        {
                public object First;