In .:
[mono.git] / mcs / class / System.Web / System.Web.UI / Control.cs
1 //
2 // System.Web.UI.Control.cs
3 //
4 // Authors:
5 //   Bob Smith <bob@thestuff.net>
6 //   Gonzalo Paniagua Javier (gonzalo@ximian.com
7 //   Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 //   Sanjay Gupta (gsanjay@novell.com)
9 //
10 // (C) Bob Smith
11 // (c) 2002,2003 Ximian, Inc. (http://www.ximian.com)
12 // (C) 2004 Novell, Inc. (http://www.novell.com)
13 //
14
15 //
16 // Permission is hereby granted, free of charge, to any person obtaining
17 // a copy of this software and associated documentation files (the
18 // "Software"), to deal in the Software without restriction, including
19 // without limitation the rights to use, copy, modify, merge, publish,
20 // distribute, sublicense, and/or sell copies of the Software, and to
21 // permit persons to whom the Software is furnished to do so, subject to
22 // the following conditions:
23 // 
24 // The above copyright notice and this permission notice shall be
25 // included in all copies or substantial portions of the Software.
26 // 
27 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
28 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
29 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
30 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
31 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
32 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
33 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34 //
35
36 // This will provide extra information when trace is enabled. Might be too verbose.
37 #define MONO_TRACE
38
39 using System.Collections;
40 using System.ComponentModel;
41 using System.ComponentModel.Design;
42 using System.ComponentModel.Design.Serialization;
43 using System.Security.Permissions;
44 using System.Web;
45 using System.Web.Util;
46 #if NET_2_0
47 using System.Web.UI.Adapters;
48 using System.IO;
49 #endif
50
51 namespace System.Web.UI
52 {
53         // CAS
54         [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
55         [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
56         // attributes
57         [DefaultProperty ("ID"), DesignerCategory ("Code"), ToolboxItemFilter ("System.Web.UI", ToolboxItemFilterType.Require)]
58         [ToolboxItem ("System.Web.UI.Design.WebControlToolboxItem, " + Consts.AssemblySystem_Design)]
59         [Designer ("System.Web.UI.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
60 #if NET_2_0
61         [DesignerSerializer ("Microsoft.VisualStudio.Web.WebForms.ControlCodeDomSerializer, " + Consts.AssemblyMicrosoft_VisualStudio_Web,
62                                 "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
63         [Bindable (true)]
64         [Themeable (false)]
65 #else
66         [DesignerSerializer ("Microsoft.VSDesigner.WebForms.ControlCodeDomSerializer, " + Consts.AssemblyMicrosoft_VSDesigner,
67                                 "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
68 #endif          
69         public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor
70 #if NET_2_0
71         , IUrlResolutionService, IControlBuilderAccessor, IControlDesignerAccessor, IExpressionsAccessor
72 #endif
73         {
74                 static readonly object DataBindingEvent = new object();
75                 static readonly object DisposedEvent = new object();
76                 static readonly object InitEvent = new object();
77                 static readonly object LoadEvent = new object();
78                 static readonly object PreRenderEvent = new object();
79                 static readonly object UnloadEvent = new object();
80                 static string[] defaultNameArray;
81                 /* */
82                 int event_mask;
83                 const int databinding_mask = 1;
84                 const int disposed_mask = 1 << 1;
85                 const int init_mask = 1 << 2;
86                 const int load_mask = 1 << 3;
87                 const int prerender_mask = 1 << 4;
88                 const int unload_mask = 1 << 5;
89                 /* */
90
91                 string uniqueID;
92                 string _userId;
93                 TemplateControl _templateControl;
94                 ControlCollection _controls;
95                 Control _namingContainer;
96                 Page _page;
97                 Control _parent;
98                 ISite _site;
99                 HttpContext _context;
100                 StateBag _viewState;
101                 EventHandlerList _events;
102                 RenderMethod _renderMethodDelegate;
103                 int defaultNumberID;
104  
105                 DataBindingCollection dataBindings;
106                 Hashtable pendingVS; // may hold unused viewstate data from child controls
107                 
108
109                 /*************/
110                 int stateMask;
111                 const int ENABLE_VIEWSTATE      = 1;
112                 const int VISIBLE               = 1 << 1;
113                 const int AUTOID                = 1 << 2;
114                 const int CREATING_CONTROLS     = 1 << 3;
115                 const int BINDING_CONTAINER     = 1 << 4;
116                 const int AUTO_EVENT_WIREUP     = 1 << 5;
117                 const int IS_NAMING_CONTAINER   = 1 << 6;
118                 const int VISIBLE_CHANGED       = 1 << 7;
119                 const int TRACK_VIEWSTATE       = 1 << 8;
120                 const int CHILD_CONTROLS_CREATED = 1 << 9;
121                 const int ID_SET                = 1 << 10;
122                 const int INITED                = 1 << 11;
123                 const int INITING               = 1 << 12;
124                 const int VIEWSTATE_LOADED      = 1 << 13;
125                 const int LOADED                = 1 << 14;
126                 const int PRERENDERED           = 1 << 15;
127 #if NET_2_0
128                 const int ENABLE_THEMING        = 1 << 16;
129 #endif
130                 /*************/
131                 
132                 static Control ()
133                 {
134                         defaultNameArray = new string [100];
135                         for (int i = 0 ; i < 100 ; i++)
136                                 defaultNameArray [i] = "_ctl" + i;
137                 }
138
139                 public Control()
140                 {
141                         stateMask = ENABLE_VIEWSTATE | VISIBLE | AUTOID | BINDING_CONTAINER | AUTO_EVENT_WIREUP;
142                         if (this is INamingContainer)
143                                 stateMask |= IS_NAMING_CONTAINER;
144 #if NET_2_0
145                         stateMask |= ENABLE_THEMING;
146 #endif
147                 }
148
149 #if NET_2_0
150                 [MonoTODO]
151                 protected ControlAdapter Adapter 
152                 {
153                         get {
154                                 // for the time being, fool the
155                                 // Control machinery into thinking we
156                                 // don't have an Adapter.  This will
157                                 // allow us to write all the rest of
158                                 // the Adapter handling code without
159                                 // having to worry about *having*
160                                 // adapters.
161                                 return null;
162                         }
163                 }
164
165                 [EditorBrowsable (EditorBrowsableState.Advanced)]
166                 [Browsable (false)]
167                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
168                 public string AppRelativeTemplateSourceDirectory 
169                 {
170                         get {
171                                 throw new NotImplementedException ();
172                         }
173                         [EditorBrowsable (EditorBrowsableState.Never)]
174                         set {
175                                 throw new NotImplementedException ();
176                         }
177                 }
178                 
179 #endif          
180
181                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
182                 [EditorBrowsable (EditorBrowsableState.Never), Browsable (false)]
183                 public Control BindingContainer {
184                         get {
185                                 Control container = NamingContainer;
186                                 if ((container.stateMask & BINDING_CONTAINER) == 0)
187                                         container = container.BindingContainer;
188                                 return container;
189                         }
190                 }
191
192                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
193                 [Browsable (false)]
194                 [WebSysDescription ("An Identification of the control that is rendered.")]
195                 public virtual string ClientID {
196                         get {
197                                 string client = UniqueID;
198
199                                 if (client != null)
200                                         client = client.Replace (':', '_');
201
202                                 return client;
203                         }
204                 }
205
206 #if NET_2_0
207                 protected char ClientIDSeparator 
208                 {
209                         get {
210                                 throw new NotImplementedException ();
211                         }
212                 }
213 #endif          
214
215                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
216                 [Browsable (false)]
217                 [WebSysDescription ("The child controls of this control.")]
218                 public virtual ControlCollection Controls //DIT
219                 {
220                         get
221                         {
222                                 if (_controls == null) _controls = CreateControlCollection();
223                                 return _controls;
224                         }
225                 }
226
227 #if NET_2_0
228                 protected internal bool DesignMode 
229                 {
230                         get {
231                                 throw new NotImplementedException ();
232                         }
233                 }
234 #endif          
235
236                 [DefaultValue (true), WebCategory ("Behavior")]
237                 [WebSysDescription ("An Identification of the control that is rendered.")]
238 #if NET_2_0
239                 [Themeable (false)]
240 #endif                
241                 public virtual bool EnableViewState {
242                         get { return ((stateMask & ENABLE_VIEWSTATE) != 0); }
243                         set { SetMask (ENABLE_VIEWSTATE, value); }
244                 }
245                 
246                 [MergableProperty (false), ParenthesizePropertyName (true)]
247                 [WebSysDescription ("The name of the control that is rendered.")]
248 #if NET_2_0
249                 [Filterable (false), Themeable (false)]
250 #endif                
251
252                 public virtual string ID {
253                         get {
254                                 return (((stateMask & ID_SET) != 0) ? _userId : null);
255                         }
256                         
257                         set {
258                                 if (value == "")
259                                         value = null;
260
261                                 stateMask |= ID_SET;
262                                 _userId = value;
263                                 NullifyUniqueID ();
264                         }
265                 }
266
267 #if NET_2_0
268                 protected char IdSeparator 
269                 {
270                         get {
271                                 throw new NotImplementedException ();
272                         }
273                 }
274
275                 protected internal bool IsChildControlStateCleared 
276                 {
277                         get {
278                                 throw new NotImplementedException ();
279                         }
280                 }
281
282                 protected internal bool IsViewStateEnabled 
283                 {
284                         get {
285                                 throw new NotImplementedException ();
286                         }
287                 }
288
289                 protected bool LoadViewStateByID 
290                 {
291                         get {
292                                 throw new NotImplementedException ();
293                         }
294                 }
295 #endif          
296                 
297                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
298                 [Browsable (false)]
299                 [WebSysDescription ("The container that this control is part of. The control's name has to be unique within the container.")]
300                 public virtual Control NamingContainer {
301                         get {
302                                 if (_namingContainer == null && _parent != null) {
303                                         if ((_parent.stateMask & IS_NAMING_CONTAINER) == 0)
304                                                 _namingContainer = _parent.NamingContainer;
305                                         else
306                                                 _namingContainer = _parent;
307                                 }
308
309                                 return _namingContainer;
310                         }
311                 }
312
313                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
314                 [Browsable (false)]
315                 [WebSysDescription ("The webpage that this control resides on.")]
316 #if NET_2_0
317                 [Bindable (false)]
318 #endif                
319                 public virtual Page Page //DIT
320                 {
321                         get
322                         {
323                                 if (_page == null && _parent != null) _page = _parent.Page;
324                                 return _page;
325                         }
326                         set
327                         {
328                                 _page = value;
329                         }
330                 }
331
332                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
333                 [Browsable (false)]
334                 [WebSysDescription ("The parent control of this control.")]
335                 public virtual Control Parent //DIT
336                 {
337                         get
338                         {
339                                 return _parent;
340                         }
341                 }
342
343                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
344                 [EditorBrowsable (EditorBrowsableState.Advanced), Browsable (false)]
345                 [WebSysDescription ("The site this control is part of.")]
346                 public ISite Site //DIT
347                 {
348                         get
349                         {
350                                 return _site;
351                         }
352                         set
353                         {
354                                 _site = value;
355                         }
356                 }
357
358 #if NET_2_0
359                 [Browsable (false)]
360                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
361                 public TemplateControl TemplateControl 
362                 {
363                         get {
364                                 return _templateControl;
365                         }
366                         [EditorBrowsable (EditorBrowsableState.Never)]
367                         set {
368                                 _templateControl = value;
369                         }
370                 }
371 #endif          
372
373                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
374                 [Browsable (false)]
375                 [WebSysDescription ("A virtual directory containing the parent of the control.")]
376                 public virtual string TemplateSourceDirectory {
377                         get { return (_parent == null) ? String.Empty : _parent.TemplateSourceDirectory; }
378                 }
379
380                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
381                 [Browsable (false)]
382                 [WebSysDescription ("The unique ID of the control.")]
383                 public virtual string UniqueID {
384                         get {
385                                 if (uniqueID != null)
386                                         return uniqueID;
387
388                                 if (_namingContainer == null) {
389                                         if ((stateMask & IS_NAMING_CONTAINER) == 0)
390                                                 _namingContainer = NamingContainer;
391                                         if (_namingContainer == null)
392                                                 return _userId;
393                                 }
394
395                                 if (_userId == null)
396                                         _userId = _namingContainer.GetDefaultName ();
397
398                                 string prefix = _namingContainer.UniqueID;
399                                 if (_namingContainer == _page || prefix == null) {
400                                         uniqueID = _userId;
401                                         return uniqueID;
402                                 }
403
404                                 uniqueID = prefix + ":" + _userId;
405                                 return uniqueID;
406                         }
407                 }
408
409                 void SetMask (int m, bool val)
410                 {
411                         if (val)
412                                 stateMask |= m;
413                         else
414                                 stateMask &= ~m;
415                 }
416                 
417                 [DefaultValue (true), Bindable (true), WebCategory ("Behavior")]
418                 [WebSysDescription ("Visiblity state of the control.")]
419                 public virtual bool Visible {
420                         get {
421                                 if ((stateMask & VISIBLE) == 0)
422                                         return false;
423
424                                 if (_parent != null)
425                                         return _parent.Visible;
426
427                                 return true;
428                         }
429
430                         set {
431                                 if ((value && (stateMask & VISIBLE) == 0) ||
432                                     (!value && (stateMask & VISIBLE) != 0)) {
433                                         if (IsTrackingViewState)
434                                                 stateMask |= VISIBLE_CHANGED;
435                                 }
436
437                                 SetMask (VISIBLE, value);
438                         }
439                 }
440
441                 protected bool ChildControlsCreated {
442                         get { return ((stateMask & CHILD_CONTROLS_CREATED) != 0); }
443                         set {
444                                 if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0) {
445                                         if (_controls != null)
446                                                 _controls.Clear();
447                                 }
448
449                                 SetMask (CHILD_CONTROLS_CREATED, value);
450                         }
451                 }
452
453                 [Browsable (false)]
454                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
455                 protected virtual HttpContext Context //DIT
456                 {
457                         get
458                         {
459                                 HttpContext context;
460                                 if (_context != null)
461                                         return _context;
462                                 if (_parent == null)
463                                         return HttpContext.Current;
464                                 context = _parent.Context;
465                                 if (context != null)
466                                         return context;
467                                 return HttpContext.Current;
468                         }
469                 }
470
471                 protected EventHandlerList Events {
472                         get {
473                                 if (_events == null)
474                                         _events = new EventHandlerList ();
475                                 return _events;
476                         }
477                 }
478
479                 protected bool HasChildViewState {
480                         get {
481                                 return (pendingVS != null && pendingVS.Count > 0);
482                         }
483                 }
484
485                 protected bool IsTrackingViewState {
486                         get { return ((stateMask & TRACK_VIEWSTATE) != 0); }
487                 }
488
489                 [Browsable (false)]
490                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
491                 [WebSysDescription ("ViewState")]
492                 protected virtual StateBag ViewState
493                 {
494                         get
495                         {
496                                 if(_viewState == null)
497                                         _viewState = new StateBag (ViewStateIgnoresCase);
498
499                                 if (IsTrackingViewState)
500                                         _viewState.TrackViewState ();
501
502                                 return _viewState;
503                         }
504                 }
505
506                 [Browsable (false)]
507                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
508                 protected virtual bool ViewStateIgnoresCase
509                 {
510                         get {
511                                 return false;
512                         }
513                 }
514
515                 internal bool AutoEventWireup {
516                         get { return (stateMask & AUTO_EVENT_WIREUP) != 0; }
517                         set { SetMask (AUTO_EVENT_WIREUP, value); }
518                 }
519
520                 internal void SetBindingContainer (bool isBC)
521                 {
522                         SetMask (BINDING_CONTAINER, isBC);
523                 }
524
525                 internal void ResetChildNames ()
526                 {
527                         defaultNumberID = 0;
528                 }
529
530                 string GetDefaultName ()
531                 {
532                         string defaultName;
533                         if (defaultNumberID > 99) {
534                                 defaultName = "_ctl" + defaultNumberID++;
535                         } else {
536                                 defaultName = defaultNameArray [defaultNumberID++];
537                         }
538                         return defaultName;
539                 }
540
541                 void NullifyUniqueID ()
542                 {
543                         uniqueID = null;
544                         if (!HasControls ())
545                                 return;
546
547                         foreach (Control c in _controls)
548                                 c.NullifyUniqueID ();
549                 }
550
551                 protected internal virtual void AddedControl (Control control, int index)
552                 {
553                         /* Ensure the control don't have more than 1 parent */
554                         if (control._parent != null)
555                                 control._parent.Controls.Remove (control);
556
557                         control._parent = this;
558                         control._page = _page;
559                         Control nc = ((stateMask & IS_NAMING_CONTAINER) != 0) ? this : NamingContainer;
560
561                         if (nc != null) {
562                                 control._namingContainer = nc;
563                                 if (control.AutoID == true && control._userId == null)
564                                         control._userId =  nc.GetDefaultName ();
565                         }
566
567                         if ((stateMask & (INITING | INITED)) != 0)
568                                 control.InitRecursive (nc);
569
570                         if ((stateMask & (VIEWSTATE_LOADED | LOADED)) != 0) {
571                                 if (pendingVS != null) {
572                                         object vs = pendingVS [index];
573                                         if (vs != null) {
574                                                 pendingVS.Remove (index);
575                                                 if (pendingVS.Count == 0)
576                                                         pendingVS = null;
577                                         
578                                                 control.LoadViewStateRecursive (vs);
579                                         }
580                                 }
581                         }
582
583                         if ((stateMask & LOADED) != 0)
584                                 control.LoadRecursive ();
585                         
586                         if ((stateMask & PRERENDERED) != 0)
587                                 control.PreRenderRecursiveInternal ();
588                 }
589
590                 protected virtual void AddParsedSubObject(object obj) //DIT
591                 {
592                         Control c = obj as Control;
593                         if (c != null) Controls.Add(c);
594                 }
595
596 #if NET_2_0
597                 [MonoTODO]
598                 [EditorBrowsable (EditorBrowsableState.Advanced)]
599                 public virtual void ApplyStyleSheetSkin (Page page)
600                 {
601                         if (!EnableTheming) /* this enough? */
602                                 return;
603
604                         /* apply the style sheet skin here */
605                         if (page.StyleSheetTheme != null) {
606                                 ControlSkin cs = page.StyleSheetPageTheme.GetControlSkin (GetType(), SkinID);
607                                 if (cs != null)
608                                         cs.ApplySkin (this);
609                         }
610                 }
611 #endif          
612
613                 protected void BuildProfileTree(string parentId, bool calcViewState)
614                 {
615                         //TODO
616                 }
617
618 #if NET_2_0
619                 protected void ClearChildControlState ()
620                 {
621                         throw new NotImplementedException ();
622                 }
623
624                 protected void ClearChildState ()
625                 {
626                         throw new NotImplementedException ();
627                 }
628 #endif          
629
630                 protected void ClearChildViewState ()
631                 {
632                         pendingVS = null;
633                 }
634
635 #if NET_2_0
636                 protected internal
637 #else
638                 protected
639 #endif          
640                 virtual void CreateChildControls() {} //DIT
641                 
642                 protected virtual ControlCollection CreateControlCollection() //DIT
643                 {
644                         return new ControlCollection(this);
645                 }
646
647                 protected virtual void EnsureChildControls ()
648                 {
649                         if (ChildControlsCreated == false && (stateMask & CREATING_CONTROLS) == 0) {
650                                 stateMask |= CREATING_CONTROLS;
651 #if NET_2_0
652                                 if (Adapter != null)
653                                         Adapter.CreateChildControls ();
654                                 else
655 #endif
656                                         CreateChildControls();
657                                 ChildControlsCreated = true;
658                                 stateMask &= ~CREATING_CONTROLS;
659                         }
660                 }
661
662 #if NET_2_0
663                 protected void EnsureID ()
664                 {
665                         throw new NotImplementedException ();
666                 }
667
668                 protected bool HasEvents ()
669                 {
670                         throw new NotImplementedException ();
671                 }
672                 
673 #endif
674                 
675
676                 protected bool IsLiteralContent()
677                 {
678                         if (HasControls () && _controls.Count == 1 && (_controls [0] is LiteralControl))
679                                 return true;
680
681                         return false;
682                 }
683
684                 [WebSysDescription ("")]
685                 public virtual Control FindControl (string id)
686                 {
687                         return FindControl (id, 0);
688                 }
689
690                 Control LookForControlByName (string id)
691                 {
692                         if (!HasControls ())
693                                 return null;
694
695                         Control result = null;
696                         foreach (Control c in _controls) {
697                                 if (String.Compare (id, c._userId, true) == 0) {
698                                         if (result != null && result != c) {
699                                                 throw new HttpException ("1 Found more than one control with ID '" + id + "'");
700                                         }
701
702                                         result = c;
703                                         continue;
704                                 }
705
706                                 if ((c.stateMask & IS_NAMING_CONTAINER) == 0 && c.HasControls ()) {
707                                         Control child = c.LookForControlByName (id);
708                                         if (child != null) {
709                                                 if (result != null && result != child)
710                                                         throw new HttpException ("2 Found more than one control with ID '" + id + "'");
711
712                                                 result = child;
713                                         }
714                                 }
715                         }
716
717                         return result;
718                 }
719
720                 protected virtual Control FindControl (string id, int pathOffset)
721                 {
722                         EnsureChildControls ();
723                         Control namingContainer = null;
724                         if ((stateMask & IS_NAMING_CONTAINER) == 0) {
725                                 namingContainer = NamingContainer;
726                                 if (namingContainer == null)
727                                         return null;
728
729                                 return namingContainer.FindControl (id, pathOffset);
730                         }
731
732                         if (!HasControls ())
733                                 return null;
734
735                         int colon = id.IndexOf (':', pathOffset);
736                         if (colon == -1)
737                                 return LookForControlByName (id.Substring (pathOffset));
738                         
739                         string idfound = id.Substring (pathOffset, colon - pathOffset);
740                         namingContainer = LookForControlByName (idfound);
741                         if (namingContainer == null)
742                                 return null;
743
744                         return namingContainer.FindControl (id, colon + 1);
745                 }
746
747                 protected virtual void LoadViewState(object savedState)
748                 {
749                         if (savedState != null) {
750                                 ViewState.LoadViewState (savedState);
751                                 object o = ViewState ["Visible"];
752                                 if (o != null) {
753                                         SetMask (VISIBLE, (bool) o);
754                                         stateMask |= VISIBLE_CHANGED;
755                                 }
756                         }
757                 }
758
759                 [MonoTODO("Secure?")]
760                 protected string MapPathSecure(string virtualPath)
761                 {
762                         string combined = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);
763                         return Context.Request.MapPath (combined);
764                 }
765
766                 protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT
767                 {
768 #if MONO_TRACE
769                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
770                         string type_name = null;
771                         if (trace != null) {
772                                 type_name = GetType ().Name;
773                                 trace.Write ("control", String.Format ("OnBubbleEvent {0} {1}", _userId, type_name));
774                         }
775 #endif
776                         return false;
777                 }
778
779                 protected virtual void OnDataBinding (EventArgs e)
780                 {
781                         if ((event_mask & databinding_mask) != 0) {
782                                 EventHandler eh = (EventHandler)(_events [DataBindingEvent]);
783                                 if (eh != null) {
784 #if MONO_TRACE
785                                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
786                                         string type_name = null;
787                                         if (trace != null) {
788                                                 type_name = GetType ().Name;
789                                                 trace.Write ("control", String.Format ("OnDataBinding {0} {1}", _userId, type_name));
790                                         }
791 #endif
792                                         eh (this, e);
793                                 }
794                         }
795                 }
796
797 #if NET_2_0
798                 protected internal
799 #else           
800                 protected
801 #endif          
802                 virtual void OnInit (EventArgs e)
803                 {
804                         if ((event_mask & init_mask) != 0) {
805                                 EventHandler eh = (EventHandler)(_events [InitEvent]);
806                                 if (eh != null) {
807 #if MONO_TRACE
808                                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
809                                         string type_name = null;
810                                         if (trace != null) {
811                                                 type_name = GetType ().Name;
812                                                 trace.Write ("control", String.Format ("OnInit {0} {1}", _userId, type_name));
813                                         }
814 #endif
815                                         eh (this, e);
816                                 }
817                         }
818                 }
819
820 #if NET_2_0
821                 protected internal
822 #else
823                 protected
824 #endif          
825                 virtual void OnLoad (EventArgs e)
826                 {
827                         if ((event_mask & load_mask) != 0) {
828                                 EventHandler eh = (EventHandler)(_events [LoadEvent]);
829                                 if (eh != null) {
830 #if MONO_TRACE
831                                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
832                                         string type_name = null;
833                                         if (trace != null) {
834                                                 type_name = GetType ().Name;
835                                                 trace.Write ("control", String.Format ("OnLoad {0} {1}", _userId, type_name));
836                                         }
837 #endif
838                                         eh (this, e);
839                                 }
840                         }
841                 }
842
843 #if NET_2_0
844                 protected internal
845 #else
846                 protected
847 #endif
848                 virtual void OnPreRender (EventArgs e)
849                 {
850                         if ((event_mask & prerender_mask) != 0) {
851                                 EventHandler eh = (EventHandler)(_events [PreRenderEvent]);
852                                 if (eh != null) {
853 #if MONO_TRACE
854                                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
855                                         string type_name = null;
856                                         if (trace != null) {
857                                                 type_name = GetType ().Name;
858                                                 trace.Write ("control", String.Format ("OnPreRender {0} {1}", _userId, type_name));
859                                         }
860 #endif
861                                         eh (this, e);
862                                 }
863                         }
864                 }
865
866 #if NET_2_0
867                 protected internal
868 #else
869                 protected
870 #endif
871                 virtual void OnUnload(EventArgs e)
872                 {
873                         if ((event_mask & unload_mask) != 0) {
874                                 EventHandler eh = (EventHandler)(_events [UnloadEvent]);
875                                 if (eh != null) {
876 #if MONO_TRACE
877                                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
878                                         string type_name = null;
879                                         if (trace != null) {
880                                                 type_name = GetType ().Name;
881                                                 trace.Write ("control", String.Format ("OnUnload {0} {1}", _userId, type_name));
882                                         }
883 #endif
884                                         eh (this, e);
885                                 }
886                         }
887                 }
888
889 #if NET_2_0
890                 protected internal Stream OpenFile (string path)
891                 {
892                         throw new NotImplementedException ();
893                 }
894 #endif          
895
896                 protected void RaiseBubbleEvent(object source, EventArgs args)
897                 {
898                         Control c = Parent;
899                         while (c != null) {
900 #if MONO_TRACE
901                                 TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
902                                 string type_name = null;
903                                 if (trace != null) {
904                                         type_name = GetType ().Name;
905                                         trace.Write ("control", String.Format ("RaiseBubbleEvent {0} {1}", _userId, type_name));
906                                 }
907 #endif
908                                 if (c.OnBubbleEvent (source, args)) {
909 #if MONO_TRACE
910                                         if (trace != null)
911                                                 trace.Write ("control", String.Format ("End RaiseBubbleEvent (false) {0} {1}", _userId, type_name));
912 #endif
913                                         break;
914                                 }
915 #if MONO_TRACE
916                                 if (trace != null)
917                                         trace.Write ("control", String.Format ("End RaiseBubbleEvent (true) {0} {1}", _userId, type_name));
918 #endif
919                                 c = c.Parent;
920                         }
921                 }
922
923 #if NET_2_0
924                 protected internal
925 #else
926                 protected
927 #endif
928                 virtual void Render(HtmlTextWriter writer) //DIT
929                 {
930                         RenderChildren(writer);
931                 }
932
933 #if NET_2_0
934                 protected internal
935 #else
936                 protected
937 #endif
938                 virtual void RenderChildren (HtmlTextWriter writer) //DIT
939                 {
940                         if (_renderMethodDelegate != null) {
941                                 _renderMethodDelegate (writer, this);
942                         } else if (_controls != null) {
943                                 int len = _controls.Count;
944                                 for (int i = 0; i < len; i++) {
945                                         Control c = _controls [i];
946 #if NET_2_0
947                                         if (c.Adapter != null)
948                                                 c.RenderControl (writer, c.Adapter);
949                                         else
950 #endif
951                                                 c.RenderControl (writer);
952                                 }
953                         }
954                 }
955
956 #if NET_2_0
957                 protected virtual ControlAdapter ResolveAdapter ()
958                 {
959                         throw new NotImplementedException ();
960                 }
961 #endif          
962
963                 protected virtual object SaveViewState ()
964                 {
965                         if ((stateMask & VISIBLE_CHANGED) != 0) {
966                                 ViewState ["Visible"] = (stateMask & VISIBLE) != 0;
967                         } else if (_viewState == null) {
968                                 return null;
969                         }
970
971                         return _viewState.SaveViewState ();
972                 }
973
974                 protected virtual void TrackViewState()
975                 {
976                         if (_viewState != null)
977                                 _viewState.TrackViewState ();
978
979                         stateMask |= TRACK_VIEWSTATE;
980                 }
981
982                 public virtual void Dispose ()
983                 {
984                         if ((event_mask & disposed_mask) != 0) {
985                                 EventHandler eh = (EventHandler)(_events [DisposedEvent]);
986                                 if (eh != null) eh (this, EventArgs.Empty);
987                         }
988                 }
989
990                 [WebCategory ("FIXME")]
991                 [WebSysDescription ("Raised when the contols databound properties are evaluated.")]
992                 public event EventHandler DataBinding {
993                         add {
994                                 event_mask |= databinding_mask;
995                                 Events.AddHandler (DataBindingEvent, value);
996                         }
997                         remove { Events.RemoveHandler (DataBindingEvent, value); }
998                 }
999
1000                 [WebSysDescription ("Raised when the contol is disposed.")]
1001                 public event EventHandler Disposed {
1002                         add {
1003                                 event_mask |= disposed_mask;
1004                                 Events.AddHandler (DisposedEvent, value);
1005                         }
1006                         remove { Events.RemoveHandler (DisposedEvent, value); }
1007                 }
1008
1009                 [WebSysDescription ("Raised when the page containing the control is initialized.")]
1010                 public event EventHandler Init {
1011                         add {
1012                                 event_mask |= init_mask;
1013                                 Events.AddHandler (InitEvent, value);
1014                         }
1015                         remove { Events.RemoveHandler (InitEvent, value); }
1016                 }
1017
1018                 [WebSysDescription ("Raised after the page containing the control has been loaded.")]
1019                 public event EventHandler Load {
1020                         add {
1021                                 event_mask |= load_mask;
1022                                 Events.AddHandler (LoadEvent, value);
1023                         }
1024                         remove { Events.RemoveHandler (LoadEvent, value); }
1025                 }
1026
1027                 [WebSysDescription ("Raised before the page containing the control is rendered.")]
1028                 public event EventHandler PreRender {
1029                         add {
1030                                 event_mask |= prerender_mask;
1031                                 Events.AddHandler (PreRenderEvent, value);
1032                         }
1033                         remove { Events.RemoveHandler (PreRenderEvent, value); }
1034                 }
1035
1036                 [WebSysDescription ("Raised when the page containing the control is unloaded.")]
1037                 public event EventHandler Unload {
1038                         add {
1039                                 event_mask |= unload_mask;
1040                                 Events.AddHandler (UnloadEvent, value);
1041                         }
1042                         remove { Events.RemoveHandler (UnloadEvent, value); }
1043                 }
1044
1045                 public virtual void DataBind() //DIT
1046                 {
1047                         #if NET_2_0
1048                         DataBind (true);
1049                         #else
1050                         OnDataBinding (EventArgs.Empty);
1051                         DataBindChildren();
1052                         #endif
1053                 }
1054
1055                 #if NET_2_0
1056                 protected virtual
1057                 #endif
1058                 
1059                 void DataBindChildren ()
1060                 {
1061                         if (!HasControls ())
1062                                 return;
1063                         
1064                         int len = _controls.Count;
1065                         for (int i = 0; i < len; i++) {
1066                                 Control c = _controls [i];
1067                                 c.DataBind ();
1068                         }
1069                 }
1070
1071
1072                 public virtual bool HasControls ()
1073                 {
1074                     return (_controls != null && _controls.Count > 0);
1075                 }
1076
1077 #if NET_2_0
1078                 public virtual
1079 #else
1080                 public
1081 #endif
1082                 void RenderControl (HtmlTextWriter writer)
1083                 {
1084                         if ((stateMask & VISIBLE) != 0) {
1085                                 HttpContext ctx = Context;
1086                                 TraceContext trace = (ctx != null) ? ctx.Trace : null;
1087                                 int pos = 0;
1088                                 if ((trace != null) && trace.IsEnabled)
1089                                         pos = ctx.Response.GetOutputByteCount ();
1090
1091                                 Render(writer);
1092                                 if ((trace != null) && trace.IsEnabled) {
1093                                         int size = ctx.Response.GetOutputByteCount () - pos;
1094                                         trace.SaveSize (this, size >= 0 ? size : 0);
1095                                 }
1096                         }
1097                 }
1098
1099 #if NET_2_0
1100                 protected void RenderControl (HtmlTextWriter writer,
1101                                               ControlAdapter adapter)
1102                 {
1103                         if ((stateMask & VISIBLE) != 0) {
1104                                 adapter.BeginRender (writer);
1105                                 adapter.Render (writer);
1106                                 adapter.EndRender (writer);
1107                         }
1108                 }
1109 #endif          
1110
1111                 public string ResolveUrl (string relativeUrl)
1112                 {
1113                         if (relativeUrl == null)
1114                                 throw new ArgumentNullException ("relativeUrl");
1115
1116                         if (relativeUrl == "")
1117                                 return "";
1118
1119                         if (relativeUrl [0] == '#')
1120                                 return relativeUrl;
1121                         
1122                         string ts = TemplateSourceDirectory;
1123                         if (ts == "" || !UrlUtils.IsRelativeUrl (relativeUrl))
1124                                 return relativeUrl;
1125
1126                         HttpResponse resp = Context.Response;
1127                         return resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
1128                 }
1129                 
1130                 internal bool HasRenderMethodDelegate () {
1131                         return _renderMethodDelegate != null;
1132                 }
1133
1134                 [EditorBrowsable (EditorBrowsableState.Advanced)]
1135                 public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT
1136                 {
1137                         _renderMethodDelegate = renderMethod;
1138                 }
1139
1140                 internal void LoadRecursive()
1141                 {
1142 #if MONO_TRACE
1143                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1144                         string type_name = null;
1145                         if (trace != null) {
1146                                 type_name = GetType ().Name;
1147                                 trace.Write ("control", String.Format ("LoadRecursive {0} {1}", _userId, type_name));
1148                         }
1149 #endif
1150 #if NET_2_0
1151                         if (Adapter != null)
1152                                 Adapter.OnLoad (EventArgs.Empty);
1153                         else
1154 #endif
1155                                 OnLoad (EventArgs.Empty);
1156                         if (HasControls ()) {
1157                                 int len = _controls.Count;
1158                                 for (int i=0;i<len;i++)
1159                                 {
1160                                         Control c = _controls[i];
1161                                         c.LoadRecursive ();
1162                                 }
1163                         }
1164
1165 #if MONO_TRACE
1166                         if (trace != null)
1167                                 trace.Write ("control", String.Format ("End LoadRecursive {0} {1}", _userId, type_name));
1168 #endif
1169                         stateMask |= LOADED;
1170                 }
1171
1172                 internal void UnloadRecursive(Boolean dispose)
1173                 {
1174 #if MONO_TRACE
1175                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1176                         string type_name = null;
1177                         if (trace != null) {
1178                                 type_name = GetType ().Name;
1179                                 trace.Write ("control", String.Format ("UnloadRecursive {0} {1}", _userId, type_name));
1180                         }
1181 #endif
1182                         if (HasControls ()) {
1183                                 int len = _controls.Count;
1184                                 for (int i=0;i<len;i++)
1185                                 {
1186                                         Control c = _controls[i];                                       
1187                                         c.UnloadRecursive (dispose);
1188                                 }
1189                         }
1190
1191 #if MONO_TRACE
1192                         if (trace != null)
1193                                 trace.Write ("control", String.Format ("End UnloadRecursive {0} {1}", _userId, type_name));
1194 #endif
1195 #if NET_2_0
1196                         if (Adapter != null)
1197                                 Adapter.OnUnload (EventArgs.Empty);
1198                         else
1199 #endif
1200                                 OnUnload (EventArgs.Empty);
1201                         if (dispose)
1202                                 Dispose();
1203                 }
1204
1205                 internal void PreRenderRecursiveInternal()
1206                 {
1207                         if ((stateMask & VISIBLE) != 0) {
1208                                 EnsureChildControls ();
1209 #if MONO_TRACE
1210                                 TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1211                                 string type_name = null;
1212                                 if (trace != null) {
1213                                         type_name = GetType ().Name;
1214                                         trace.Write ("control", String.Format ("PreRenderRecursive {0} {1}", _userId, type_name));
1215                                 }
1216 #endif
1217 #if NET_2_0
1218                                 if (Adapter != null)
1219                                         Adapter.OnPreRender (EventArgs.Empty);
1220                                 else
1221 #endif
1222                                         OnPreRender (EventArgs.Empty);
1223                                 if (!HasControls ())
1224                                         return;
1225                                 
1226                                 int len = _controls.Count;
1227                                 for (int i=0;i<len;i++)
1228                                 {
1229                                         Control c = _controls[i];
1230                                         c.PreRenderRecursiveInternal ();
1231                                 }
1232 #if MONO_TRACE
1233                                 if (trace != null)
1234                                         trace.Write ("control", String.Format ("End PreRenderRecursive {0} {1}", _userId, type_name));
1235 #endif
1236                         }
1237                         stateMask |= PRERENDERED;
1238                 }
1239
1240                 internal void InitRecursive(Control namingContainer)
1241                 {
1242 #if MONO_TRACE
1243                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1244                         string type_name = null;
1245                         if (trace != null) {
1246                                 type_name = GetType ().Name;
1247                                 trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
1248                         }
1249 #endif
1250
1251                         if (HasControls ()) {
1252                                 if ((stateMask & IS_NAMING_CONTAINER) != 0)
1253                                         namingContainer = this;
1254
1255                                 if (namingContainer != null && 
1256                                     namingContainer._userId == null &&
1257                                     namingContainer.AutoID)
1258                                         namingContainer._userId = namingContainer.GetDefaultName () + "b";
1259
1260                                 int len = _controls.Count;
1261                                 for (int i=0;i<len;i++)
1262                                 {
1263                                         Control c = _controls[i];
1264                                         c._page = Page;
1265                                         c._namingContainer = namingContainer;
1266                                         if (namingContainer != null && c._userId == null && c.AutoID)
1267                                                 c._userId = namingContainer.GetDefaultName () + "c";
1268                                         c.InitRecursive (namingContainer);      
1269                                 }
1270                         }
1271
1272                         stateMask |= INITING;
1273 #if NET_2_0
1274                         if (Adapter != null)
1275                                 Adapter.OnInit (EventArgs.Empty);
1276                         else
1277 #endif
1278                                 OnInit (EventArgs.Empty);
1279 #if MONO_TRACE
1280                         if (trace != null)
1281                                 trace.Write ("control", String.Format ("End InitRecursive {0} {1}", _userId, type_name));
1282 #endif
1283                         TrackViewState ();
1284                         stateMask |= INITED;
1285                         stateMask &= ~INITING;
1286                 }
1287
1288                 internal object SaveViewStateRecursive ()
1289                 {
1290                         if (!EnableViewState)
1291                                 return null;
1292
1293 #if MONO_TRACE
1294                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1295                         string type_name = null;
1296                         if (trace != null) {
1297                                 type_name = GetType ().Name;
1298                                 trace.Write ("control", String.Format ("SaveViewStateRecursive {0} {1}", _userId, type_name));
1299                         }
1300 #endif
1301
1302                         ArrayList controlList = null;
1303                         ArrayList controlStates = null;
1304
1305                         int idx = -1;
1306                         if (HasControls ())
1307                         {
1308                                 int len = _controls.Count;
1309                                 for (int i=0;i<len;i++)
1310                                 {
1311                                         Control ctrl = _controls[i];
1312                                         object ctrlState = ctrl.SaveViewStateRecursive ();
1313                                         idx++;
1314                                         if (ctrlState == null)
1315                                                 continue;
1316
1317                                         if (controlList == null) 
1318                                         {
1319                                                 controlList = new ArrayList ();
1320                                                 controlStates = new ArrayList ();
1321                                         }
1322
1323                                         controlList.Add (idx);
1324                                         controlStates.Add (ctrlState);
1325                                 }
1326                         }
1327
1328                         object thisState = SaveViewState ();
1329                         if (thisState == null && controlList == null && controlStates == null) {
1330 #if MONO_TRACE
1331                                 if (trace != null) {
1332                                         trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved nothing", _userId, type_name));
1333                                         trace.SaveViewState (this, null);
1334                                 }
1335 #endif
1336                                 return null;
1337                         }
1338
1339 #if MONO_TRACE
1340                         if (trace != null) {
1341                                 trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved a Triplet", _userId, type_name));
1342                                 trace.SaveViewState (this, thisState);
1343                         }
1344 #endif
1345                         return new Triplet (thisState, controlList, controlStates);
1346                 }
1347                 
1348                 internal void LoadViewStateRecursive (object savedState)
1349                 {
1350                         if (!EnableViewState || savedState == null)
1351                                 return;
1352
1353 #if MONO_TRACE
1354                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1355                         string type_name = null;
1356                         if (trace != null) {
1357                                 type_name = GetType ().Name;
1358                                 trace.Write ("control", String.Format ("LoadViewStateRecursive {0} {1}", _userId, type_name));
1359                         }
1360 #endif
1361                         Triplet savedInfo = (Triplet) savedState;
1362                         LoadViewState (savedInfo.First);
1363
1364                         ArrayList controlList = savedInfo.Second as ArrayList;
1365                         if (controlList == null)
1366                                 return;
1367                         ArrayList controlStates = savedInfo.Third as ArrayList;
1368                         int nControls = controlList.Count;
1369                         for (int i = 0; i < nControls; i++) {
1370                                 int k = (int) controlList [i];
1371                                 if (k < Controls.Count && controlStates != null) {
1372                                         Control c = Controls [k];
1373                                         c.LoadViewStateRecursive (controlStates [i]);
1374                                 } else {
1375                                         if (pendingVS == null)
1376                                                 pendingVS = new Hashtable ();
1377
1378                                         pendingVS [k] = controlStates [i];
1379                                 }
1380                         }
1381
1382 #if MONO_TRACE
1383                         if (trace != null)
1384                                 trace.Write ("control", String.Format ("End LoadViewStateRecursive {0} {1}", _userId, type_name));
1385 #endif
1386                         stateMask |= VIEWSTATE_LOADED;
1387                 }
1388
1389 #if NET_2_0
1390                 internal ControlSkin controlSkin;
1391
1392                 internal void ApplyThemeRecursive ()
1393                 {
1394 #if MONO_TRACE
1395                         TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
1396                         string type_name = null;
1397                         if (trace != null) {
1398                                 type_name = GetType ().Name;
1399                                 trace.Write ("control", String.Format ("ApplyThemeRecursive {0} {1}", _userId, type_name));
1400                         }
1401 #endif
1402                         ControlSkin controlSkin = Page.PageTheme.GetControlSkin (GetType(), SkinID);
1403                         if (controlSkin != null)
1404                                 controlSkin.ApplySkin (this);
1405
1406                         if (HasControls ()) {
1407                                 int len = _controls.Count;
1408                                 for (int i=0;i<len;i++)
1409                                 {
1410                                         Control c = _controls[i];
1411                                         c.ApplyThemeRecursive ();
1412                                 }
1413                         }
1414
1415 #if MONO_TRACE
1416                         if (trace != null)
1417                                 trace.Write ("control", String.Format ("End ApplyThemeRecursive {0} {1}", _userId, type_name));
1418 #endif
1419                 }
1420 #endif
1421                 
1422                 internal bool AutoID
1423                 {
1424                         get { return (stateMask & AUTOID) != 0; }
1425                         set {
1426                                 if (value == false && (stateMask & IS_NAMING_CONTAINER) != 0)
1427                                         return;
1428
1429                                 SetMask (AUTOID, value);
1430                         }
1431                 }
1432
1433                 protected internal virtual void RemovedControl (Control control)
1434                 {
1435                         control.UnloadRecursive (false);
1436                         control._parent = null;
1437                         control._page = null;
1438                         control._namingContainer = null;
1439                 }
1440
1441
1442 #if NET_2_0
1443
1444                 string skinId = string.Empty;
1445                 
1446                 [Browsable (false)]
1447                 [Themeable (false)]
1448                 [DefaultValue (true)]
1449                 public virtual bool EnableTheming
1450                 {
1451                         get { return (stateMask & ENABLE_THEMING) != 0; }
1452                         set { SetMask (ENABLE_THEMING, value); }
1453                 }
1454                 
1455                 [Browsable (false)]
1456                 [DefaultValue ("")]
1457                 [Filterable (false)]
1458                 public virtual string SkinID
1459                 {
1460                         get { return skinId; }
1461                         set { skinId = value; }
1462                 }
1463                 
1464                 public string ResolveClientUrl (string url)
1465                 {
1466                         throw new NotImplementedException ();               
1467                 }
1468
1469                 ControlBuilder IControlBuilderAccessor.ControlBuilder { 
1470                         get {throw new NotImplementedException (); }
1471                 }
1472
1473                 IDictionary IControlDesignerAccessor.GetDesignModeState ()
1474                 {
1475                         throw new NotImplementedException ();               
1476                 }
1477
1478                 void IControlDesignerAccessor.SetDesignModeState (IDictionary designData)
1479                 {
1480                         SetDesignModeState (designData);
1481                 }
1482         
1483                 void IControlDesignerAccessor.SetOwnerControl (Control control)
1484                 {
1485                         throw new NotImplementedException ();               
1486                 }
1487                 
1488                 IDictionary IControlDesignerAccessor.UserData { 
1489                         get { throw new NotImplementedException (); }
1490                 }
1491        
1492                 ExpressionBindingCollection expressionBindings;
1493
1494                 ExpressionBindingCollection IExpressionsAccessor.Expressions { 
1495                         get { 
1496                                 if (expressionBindings == null)
1497                                         expressionBindings = new ExpressionBindingCollection ();
1498                                 return expressionBindings;
1499                         } 
1500                 }
1501                 
1502                 bool IExpressionsAccessor.HasExpressions { 
1503                         get {
1504                                 return (expressionBindings != null && expressionBindings.Count > 0);
1505                         }
1506                 }
1507
1508                 [MonoTODO]
1509                 public virtual void Focus()
1510                 {
1511                         throw new NotImplementedException();
1512                 }
1513                 
1514                 protected internal virtual void LoadControlState (object state)
1515                 {
1516                 }
1517                 
1518                 protected internal virtual object SaveControlState ()
1519                 {
1520                         return null;
1521                 }
1522                 
1523                 protected virtual void DataBind (bool raiseOnDataBinding)
1524                 {
1525                         bool foundDataItem = false;
1526                         
1527                         if ((stateMask & IS_NAMING_CONTAINER) != 0 && Page != null) {
1528                                 object o = DataBinder.GetDataItem (this, out foundDataItem);
1529                                 if (foundDataItem)
1530                                         Page.PushDataItemContext (o);
1531                         }
1532                         
1533                         try {
1534                                 
1535                                 if (raiseOnDataBinding)
1536                                         OnDataBinding (EventArgs.Empty);
1537                                 DataBindChildren();
1538                         
1539                         } finally {
1540                                 if (foundDataItem)
1541                                         Page.PopDataItemContext ();
1542                         }
1543                 }
1544                 
1545                 protected virtual IDictionary GetDesignModeState ()
1546                 {
1547                         throw new NotImplementedException ();               
1548                 }
1549                 
1550                 protected virtual void SetDesignModeState (IDictionary data)
1551                 {
1552                         throw new NotImplementedException ();               
1553                 }
1554 #endif
1555                 void IParserAccessor.AddParsedSubObject (object obj) {
1556                         this.AddParsedSubObject (obj);
1557                 }
1558
1559                 DataBindingCollection IDataBindingsAccessor.DataBindings {
1560                         get {
1561                                 if (dataBindings == null) {
1562                                         dataBindings = new DataBindingCollection ();
1563                                 }
1564                                 return dataBindings;
1565                         }
1566                 }
1567
1568                 bool IDataBindingsAccessor.HasDataBindings {
1569                         get {
1570                                 if (dataBindings != null && dataBindings.Count > 0) {
1571                                         return true;
1572                                 }
1573                                 return false;
1574                         }
1575                 }
1576         }
1577 }