* roottypes.cs: Rename from tree.cs.
[mono.git] / mcs / class / System.Web / System.Web.UI / Control.cs
index 87c195308fd2db988965862d8b2714e245bf7793..83521a7b9de50cf2437e09220253e95467f7da32 100644 (file)
@@ -183,7 +183,7 @@ namespace System.Web.UI
                public Control BindingContainer {
                        get {
                                Control container = NamingContainer;
-                               if ((container.stateMask & BINDING_CONTAINER) == 0)
+                               if (container != null && (container.stateMask & BINDING_CONTAINER) == 0)
                                        container = container.BindingContainer;
                                return container;
                        }
@@ -281,7 +281,14 @@ namespace System.Web.UI
                protected internal bool IsViewStateEnabled 
                {
                        get {
-                               throw new NotImplementedException ();
+                               if (Page == null)
+                                       return false;
+
+                               for (Control control = this; control != null; control = control.Parent)
+                                       if (!control.EnableViewState)
+                                               return false;
+
+                               return true;
                        }
                }
 
@@ -601,7 +608,7 @@ namespace System.Web.UI
                                return;
 
                        /* apply the style sheet skin here */
-                       if (page.StyleSheetTheme != null) {
+                       if (page.StyleSheetPageTheme != null) {
                                ControlSkin cs = page.StyleSheetPageTheme.GetControlSkin (GetType(), SkinID);
                                if (cs != null)
                                        cs.ApplySkin (this);
@@ -1246,7 +1253,6 @@ namespace System.Web.UI
                                trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
                        }
 #endif
-
                         if (HasControls ()) {
                                if ((stateMask & IS_NAMING_CONTAINER) != 0)
                                        namingContainer = this;
@@ -1270,6 +1276,8 @@ namespace System.Web.UI
 
                        stateMask |= INITING;
 #if NET_2_0
+                       ApplyTheme ();
+                       
                        if (Adapter != null)
                                Adapter.OnInit (EventArgs.Empty);
                        else
@@ -1388,7 +1396,7 @@ namespace System.Web.UI
 #if NET_2_0
                internal ControlSkin controlSkin;
 
-                internal void ApplyThemeRecursive ()
+                internal void ApplyTheme ()
                 {
 #if MONO_TRACE
                        TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
@@ -1398,17 +1406,10 @@ namespace System.Web.UI
                                trace.Write ("control", String.Format ("ApplyThemeRecursive {0} {1}", _userId, type_name));
                        }
 #endif
-                       ControlSkin controlSkin = Page.PageTheme.GetControlSkin (GetType(), SkinID);
-                       if (controlSkin != null)
-                               controlSkin.ApplySkin (this);
-
-                        if (HasControls ()) {
-                               int len = _controls.Count;
-                               for (int i=0;i<len;i++)
-                               {
-                                       Control c = _controls[i];
-                                       c.ApplyThemeRecursive ();
-                               }
+                       if (Page.PageTheme != null) {
+                               ControlSkin controlSkin = Page.PageTheme.GetControlSkin (GetType (), SkinID);
+                               if (controlSkin != null)
+                                       controlSkin.ApplySkin (this);
                        }
 
 #if MONO_TRACE