-//
-// System.Web.UI.Control.cs
-//
-// Author:
-// Bob Smith <bob@thestuff.net>
-//
-// (C) Bob Smith
-//
-
-//notes: view state only tracks changes after OnInit method is executed for the page request. You can read from it at any time, but cant write to it during rendering.
-//more notes: look at the private on* methods for initialization order. they will help.
-//even more notes: view state info in trackviewstate method description. read later.
-//Ok, enough notes: what the heck is different between enable view state, and track view state.
-
-//cycle:
-//init is called when control is first created.
-//load is called when control is loaded into a page
-//prerender is called when the server is about to render its page object
-//disposed/unload not sure but is last.
-
-//read this later. http://gotdotnet.com/quickstart/aspplus/
-
-using System;
-using System.Web;
-using System.ComponentModel;
-
-namespace System.Web.UI
-{
- public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor
- {
- public event EventHandler DataBinding;
- public event EventHandler Disposed;
- public event EventHandler Init;
- public event EventHandler Load;
- public event EventHandler PreRender;
- public event EventHandler Unload;
- private string _clientId; //default to "ctrl#" where # is a static count of ctrls per page.
- private string _userId = null;
- private ControlCollection _controls;
- private bool _enableViewState = true;
- private Control _namingContainer;
- private Page _page;
- private Control _parent; //TODO: set default.
- private ISite _site; //TODO: what default?
- private bool _visible; //TODO: what default?
- private HttpContext _context = null;
- private bool _childControlsCreated = false;
- private StateBag _viewState; //TODO: help me.
- private bool _trackViewState = false; //TODO: I think this is right. Verify. Also modify other methods to use this.
- private bool _viewStateIgnoreCase = true;
- public Control()
- {
- _namingContainer = _parent;
- _viewState = new StateBag(_viewStateIgnoreCase);
- _events = new EventHandlerList();
- _controls = this.CreateControlCollection(); //FIXME: this goes here?
- }
- public ~Control()
- {
- Dispose();
- }
- public virtual string ClientID
- {
- get
- {
- return _clientId;
- }
- }
- public virtual ControlCollection Controls
- {
- get
- {
- return _controls;
- }
- }
- public virtual bool EnableViewState
- {
- get
- {
- return _enableViewState;
- }
- set
- {
- _enableViewState = value;
- }
- }
- public virtual string ID
- {
- get
- {
- if (_userId == null)
- return _clientId;
- else
- return _userId;
- }
- set
- {
- _userId = value;
- }
- }
- public virtual Control NamingContainer
- {
- get
- {
- return _namingContainer;
- }
- }
- public virtual Page Page
- {
- get
- {
- return _page;
- }
- set
- {
- _page = value;
- }
- }
- public virtual Control Parent
- {
- get
- {
- return _parent;
- }
- }
- public ISite Site
- {
- get
- {
- return _site;
- }
- set
- {
- _site = value;
- }
- }
- public virtual string TemplateSourceDirectory
- {
- get
- {
- return Context.Request.ApplicationPath;
- }
- }
- public virtual string UniqueID
- {
- get
- {
- if (_namingContainer == null)
- if (_userId == null)
- return _clientId;
- else
- return _clientId + ":" + _userId;
- else if (_userId == null)
- return _namingContainer.UniqueID + ":" + _clientId;
- return _namingContainer.UniqueID + ":" + _clientId + ":" + _userId;
- }
- }
- public virtual bool Visible
- {
- get
- {
- return _visible;
- }
- set
- {
- _visible = value;
- }
- }
- protected bool ChildControlsCreated
- {
- get
- {
- return _childControlsCreated;
- }
- set
- {
- _childControlsCreated = value;
- }
- }
- protected virtual HttpContext Context
- {
- get
- {
- HttpContext context;
- if (_context != null)
- return _context;
- if (_parent == null)
- return HttpContext.Current;
- context = _parent.Context;
- if (context != null)
- return context;
- return HttpContext.Current;
- }
- }
- protected EventHandlerList Events
- {
- get
- {
- EventHandlerList e = new EventHandlerList();
- e.AddHandler(this, DataBinding);
- e.AddHandler(this, Disposed);
- e.AddHandler(this, Init);
- e.AddHandler(this, Load);
- e.AddHandler(this, PreRender);
- e.AddHandler(this, Unload);
- return e;
- }
- }
- protected bool HasChildViewState
- {
- get
- { //FIXME: Relook over this. not sure!
- foreach (control c in _controls)
- if (c.IsTrackingViewState) return true;
- return false;
- }
- }
- protected bool IsTrackingViewState
- {
- get
- { //FIXME: ME TO!
- return _enableViewState;
- }
- }
- protected virtual StateBag ViewState
- {
- get
- {
- return _viewState;
- }
- }
- protected virtual bool ViewStateIgnoresCase
- {
- get
- {
- return _viewStateIgnoreCase;
- }
- }
- protected virtual void AddParsedSubObject(object obj)
- {
- _controls.Add(obj);
- }
- protected void BuildProfileTree(string parentId, bool calcViewState)
- {
- //TODO
- }
- protected void ClearChildViewState()
- {
- //TODO
- //Not quite sure about this. an example clears children then calls this, so I think
- //view state is local to the current object, not children.
- }
- protected virtual void CreateChildControls() {}
- protected virtual ControlCollection CreateControlCollection()
- {
- _controls = new ControlCollection(this);
- }
- protected virtual void EnsureChildControls() {} //FIXME: I think this should be empty.
- public virtual Control FindControl(string id)
- {
- int i;
- for (i = 0; i < _controls.Count; i++)
- if (_controls[i].ID == id) return _controls[i].ID;
- return null;
- }
- protected virtual Control FindControl(string id, int pathOffset)
- {
- int i;
- for (i = pathOffset; i < _controls.Count; i++)
- if (_controls[i].ID == id) return _controls[i].ID;
- return null;
- }
- protected virtual void LoadViewState(object savedState)
- {
- //TODO: What should I do by default?
- }
- protected string MapPathSecure(string virtualPath)
- {
- //TODO: Need to read up on security+web.
- }
- protected virtual bool OnBubbleEvent(object source, EventArgs args)
- {
- return false; //FIXME: It might throw "ItemCommand". not sure.
- }
- protected virtual void OnDataBinding(EventArgs e)
- {
- if (DataBinding != null) DataBinding(this, e);
- }
- protected virtual void OnInit(EventArgs e)
- {
- if (Init != null) Init(this, e);
- }
- protected virtual void OnPreRender(EventArgs e)
- {
- if (PreRender != null) PreRender(this, e);
- }
- protected virtual void OnUnload(EventArgs e)
- {
- if (Unload != null) Unload(this, e);
- }
- protected void RaiseBubbleEvent(object source, EventArgs args)
- {
- _parent.OnBubbleEvent(source, args); //FIXME: I think this is right. Check though.
- }
- protected virtual void Render(HtmlTextWriter writer) {} //FIXME: Default?
- protected virtual void RenderChildren(HtmlTextWriter writer)
- {
- //if render method delegate is set, call it here. otherwise,
- //render any child controls. just a for loop?
- }
- protected virtual object SaveViewState()
- {
- return ViewState;
- }
- protected virtual void TrackViewState()
- {
- _trackViewState = true;
- }
- public virtual void DataBind()
- {
-//TODO: I think this recursively calls this method on its children.
- }
- public virtual void Dispose()
- {
- //TODO: nuke stuff.
- if (Disposed != null) Disposed(this, e);
- }
-
-
-
-
- }
-}
+//\r
+// System.Web.UI.Control.cs\r
+//\r
+// Authors:\r
+// Bob Smith <bob@thestuff.net>\r
+// Gonzalo Paniagua Javier (gonzalo@ximian.com)\r
+//\r
+// (C) Bob Smith\r
+// (c) 2002 Ximian, Inc. (http://www.ximian.com)\r
+//\r
+\r
+/*\r
+ * Maintainer: bob@thestuff.net, gvaish@iitk.ac.in\r
+ * (C) Bob Smith, Gaurav Vaish\r
+ */\r
+\r
+//notes: view state only tracks changes after OnInit method is executed for the page request. You can read from it at any time, but cant write to it during rendering.\r
+//even more notes: view state info in trackviewstate method description. read later.\r
+//Ok, enough notes: what the heck is different between enable view state, and track view state.\r
+//Well, maybe not. How does the ViewState know when to track changes? Does it look at the property\r
+//on the owning control, or does it have a method/property of its own that gets called?\r
+// I think this last question is solved in the Interface for it. Look into this.\r
+\r
+//cycle:\r
+//init is called when control is first created.\r
+//load view state ic called right after init to populate the view state.\r
+//loadpostdata is called if ipostbackdatahandler is implemented.\r
+//load is called when control is loaded into a page\r
+//raisepostdatachangedevent if ipostbackdatahandler is implemented.\r
+//raisepostbackevent if ipostbackeventhandler is implemented.\r
+//prerender is called when the server is about to render its page object\r
+//SaveViewState is called.\r
+//Unload then dispose it apears. :)\r
+\r
+//Naming Container MUST have some methods. What are they? No clue. Help?\r
+\r
+//read this later. http://gotdotnet.com/quickstart/aspplus/\r
+//This to: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpconattributesdesign-timesupport.asp\r
+//http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguidnf/html/cpcontracefunctionality.asp\r
+\r
+// Isnt life grand? :)\r
+// See the undocumented methods? Gota love um. ;)\r
+// ASP.test4_aspx.Page_Load(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6\r
+// System.Web.UI.Control.OnLoad(EventArgs e) +67\r
+// System.Web.UI.Control.LoadRecursive() +73\r
+// System.Web.UI.Page.ProcessRequestMain() +394\r
+\r
+// ASP.test4_aspx.Page_Unload(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6\r
+// System.EventHandler.Invoke(Object sender, EventArgs e) +0\r
+// System.Web.UI.Control.OnUnload(EventArgs e) +67\r
+// System.Web.UI.Control.UnloadRecursive(Boolean dispose) +78\r
+// System.Web.UI.Page.ProcessRequest() +194\r
+// System.Web.UI.Page.ProcessRequest(HttpContext context) +18\r
+// System.Web.CallHandlerExecutionStep.Execute() +179\r
+// System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +87\r
+\r
+\r
+// ASP.test4_aspx.Page_Unload(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6\r
+// System.Web.UI.Control.OnUnload(EventArgs e) +67\r
+// System.Web.UI.Control.UnloadRecursive(Boolean dispose) +78\r
+// System.Web.UI.Page.ProcessRequest()\r
+\r
+// ASP.test4_aspx.Page_Kill(Object Sender, EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6\r
+// System.Web.UI.Control.OnPreRender(EventArgs e) +67\r
+// System.Web.UI.Control.PreRenderRecursiveInternal() +61\r
+// System.Web.UI.Page.ProcessRequestMain() +753\r
+\r
+// ASP.test4_aspx.OnInit(EventArgs e) in \\genfs2\www24\bobsmith11\test4.aspx:6\r
+// System.Web.UI.Control.InitRecursive(Control namingContainer) +202\r
+// System.Web.UI.Page.ProcessRequestMain() +120\r
+\r
+// ASP.test4_aspx.SaveViewState() in \\genfs2\www24\bobsmith11\test4.aspx:12\r
+// System.Web.UI.Control.SaveViewStateRecursive() +51\r
+// System.Web.UI.Page.SavePageViewState() +174\r
+// System.Web.UI.Page.ProcessRequestMain() +861\r
+\r
+// ASP.test_aspx.LoadViewState(Object t) +28\r
+// System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125\r
+// System.Web.UI.Page.LoadPageViewState() +182\r
+// System.Web.UI.Page.ProcessRequestMain() +256\r
+\r
+using System;\r
+using System.Collections;\r
+using System.Web;\r
+using System.ComponentModel;\r
+\r
+namespace System.Web.UI\r
+{\r
+ public class Control : IComponent, IDisposable, IParserAccessor, IDataBindingsAccessor\r
+ {\r
+ private static readonly object DataBindingEvent = new object();\r
+ private static readonly object DisposedEvent = new object();\r
+ private static readonly object InitEvent = new object();\r
+ private static readonly object LoadEvent = new object();\r
+ private static readonly object PreRenderEvent = new object();\r
+ private static readonly object UnloadEvent = new object();\r
+ private string _userId = null;\r
+ private string _cachedUserId = null;\r
+ private string _cachedClientId = null;\r
+ private ControlCollection _controls = null;\r
+ private bool _enableViewState = true;\r
+ private IDictionary _childViewStates = null; //TODO: Not sure datatype. Placeholder guess.\r
+ private bool _isNamingContainer = false;\r
+ private Control _namingContainer = null;\r
+ private Page _page = null;\r
+ private Control _parent = null;\r
+ private ISite _site = null;\r
+ private bool _visible = true;\r
+ private HttpContext _context = null;\r
+ private bool _childControlsCreated = false;\r
+ private StateBag _viewState = null;\r
+ private bool _trackViewState = false;\r
+ private EventHandlerList _events = new EventHandlerList();\r
+ private RenderMethod _renderMethodDelegate = null;\r
+ private bool autoID = true;\r
+ private bool creatingControls = false;\r
+ \r
+ private DataBindingCollection dataBindings = null;\r
+\r
+ public Control()\r
+ {\r
+ if (this is INamingContainer) _isNamingContainer = true;\r
+ }\r
+\r
+ public Control BindingContainer\r
+ {\r
+ get {\r
+ Control container = NamingContainer;\r
+ if (_isNamingContainer)\r
+ container = container.BindingContainer;\r
+ return container;\r
+ }\r
+ }\r
+ \r
+ public virtual string ClientID //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_cachedUserId != null && _cachedClientId != null)\r
+ return _cachedClientId;\r
+ _cachedUserId = UniqueID.Replace(':', '_');\r
+ return _cachedUserId;\r
+ }\r
+ }\r
+ public virtual ControlCollection Controls //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_controls == null) _controls = CreateControlCollection();\r
+ return _controls;\r
+ }\r
+ }\r
+ public virtual bool EnableViewState //DIT\r
+ {\r
+ get\r
+ {\r
+ return _enableViewState;\r
+ }\r
+ set\r
+ {\r
+ _enableViewState = value;\r
+ }\r
+ }\r
+ public virtual string ID\r
+ {\r
+ get //DIT\r
+ {\r
+ return _userId;\r
+ }\r
+ set\r
+ {\r
+ if (value == null || value == "") return;\r
+ _userId = value;\r
+ _cachedUserId = null;\r
+ //TODO: Some Naming Container stuff here I think.\r
+ }\r
+ }\r
+ public virtual Control NamingContainer //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_namingContainer == null && _parent != null)\r
+ {\r
+ if (_parent._isNamingContainer == false)\r
+ _namingContainer = _parent.NamingContainer;\r
+ else\r
+ _namingContainer = _parent;\r
+ }\r
+ return _namingContainer;\r
+ }\r
+ }\r
+ public virtual Page Page //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_page == null && _parent != null) _page = _parent.Page;\r
+ return _page;\r
+ }\r
+ set\r
+ {\r
+ _page = value;\r
+ }\r
+ }\r
+ public virtual Control Parent //DIT\r
+ {\r
+ get\r
+ {\r
+ return _parent;\r
+ }\r
+ }\r
+ public ISite Site //DIT\r
+ {\r
+ get\r
+ {\r
+ return _site;\r
+ }\r
+ set\r
+ {\r
+ _site = value;\r
+ }\r
+ }\r
+ public virtual string TemplateSourceDirectory\r
+ {\r
+ get\r
+ {\r
+ return Context.Request.ApplicationPath; //TODO: Dont think this is right.\r
+ }\r
+ }\r
+\r
+ [MonoTODO]\r
+ public virtual string UniqueID\r
+ {\r
+ get\r
+ {\r
+ //TODO: Some Naming container methods here. What are they? Why arnt they declared?\r
+ //Note: Nuked the old stuff here. Was total crap. :)\r
+ return ID;\r
+ }\r
+ }\r
+ public virtual bool Visible\r
+ {\r
+ get\r
+ {\r
+ if (_visible == false)\r
+ return false;\r
+\r
+ if (_parent != null)\r
+ return _parent.Visible;\r
+\r
+ return true;\r
+ }\r
+ set\r
+ {\r
+ _visible = value;\r
+ }\r
+ }\r
+ protected bool ChildControlsCreated //DIT\r
+ {\r
+ get\r
+ {\r
+ return _childControlsCreated;\r
+ }\r
+ set\r
+ {\r
+ if (value == false && _childControlsCreated == true)\r
+ _controls.Clear();\r
+ _childControlsCreated = value;\r
+ }\r
+ }\r
+ protected virtual HttpContext Context //DIT\r
+ {\r
+ get\r
+ {\r
+ HttpContext context;\r
+ if (_context != null)\r
+ return _context;\r
+ if (_parent == null)\r
+ return HttpContext.Current;\r
+ context = _parent.Context;\r
+ if (context != null)\r
+ return context;\r
+ return HttpContext.Current;\r
+ }\r
+ }\r
+ protected EventHandlerList Events //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_events == null)\r
+ {\r
+ _events = new EventHandlerList();\r
+ }\r
+ return _events;\r
+ }\r
+ }\r
+ protected bool HasChildViewState //DIT\r
+ {\r
+ get\r
+ {\r
+ if (_childViewStates == null) return false;\r
+ return true;\r
+ }\r
+ }\r
+ protected bool IsTrackingViewState //DIT\r
+ {\r
+ get\r
+ {\r
+ return _trackViewState;\r
+ }\r
+ }\r
+ protected virtual StateBag ViewState\r
+ {\r
+ get\r
+ {\r
+ if(_viewState == null)\r
+ _viewState = new StateBag (ViewStateIgnoresCase);\r
+\r
+ if (IsTrackingViewState)\r
+ _viewState.TrackViewState ();\r
+\r
+ return _viewState;\r
+ }\r
+ }\r
+ protected virtual bool ViewStateIgnoresCase\r
+ {\r
+ get {\r
+ return false;\r
+ }\r
+ }\r
+\r
+ private int defaultNumberID;\r
+ protected internal virtual void AddedControl (Control control, int index)\r
+ {\r
+ /* Ensure the control don't have more than 1 parent */\r
+ if (control._parent != null)\r
+ control._parent.Controls.Remove (control);\r
+\r
+ control._parent = this;\r
+ control._page = Page;\r
+\r
+ // Without this, DataBoundLiteralControl crashes in OnDataBound event.\r
+ Control namingContainer = NamingContainer;\r
+ if (namingContainer != null)\r
+ control._namingContainer = namingContainer;\r
+ \r
+ if (control.AutoID == true && control.ID == null)\r
+ control.ID = "_ctrl_" + defaultNumberID++;\r
+ }\r
+\r
+ protected virtual void AddParsedSubObject(object obj) //DIT\r
+ {\r
+ Control c = (Control)obj;\r
+ if (c != null) Controls.Add(c);\r
+ }\r
+ protected void BuildProfileTree(string parentId, bool calcViewState)\r
+ {\r
+ //TODO\r
+ }\r
+ protected void ClearChildViewState()\r
+ {\r
+ //TODO\r
+ //Not quite sure about this. an example clears children then calls this, so I think\r
+ //view state is local to the current object, not children.\r
+ }\r
+ protected virtual void CreateChildControls() {} //DIT\r
+ protected virtual ControlCollection CreateControlCollection() //DIT\r
+ {\r
+ return new ControlCollection(this);\r
+ }\r
+\r
+ protected virtual void EnsureChildControls () //DIT\r
+ {\r
+ if (ChildControlsCreated == false && !creatingControls) {\r
+ creatingControls = true;\r
+ CreateChildControls();\r
+ ChildControlsCreated = true;\r
+ creatingControls = false;\r
+ }\r
+ }\r
+\r
+ protected virtual Control FindControl(string id, int pathOffset)\r
+ {\r
+ //TODO: I think there is Naming Container stuff here. Redo.\r
+ int i;\r
+ Control ctrl;\r
+ for (i = pathOffset; i < _controls.Count; i++){\r
+ ctrl = _controls [i];\r
+ \r
+ if (ctrl.ID == id)\r
+ return ctrl;\r
+\r
+ if (ctrl.Controls.Count > 0){\r
+ Control other = ctrl.FindControl (id);\r
+ if (other != null)\r
+ return other;\r
+ }\r
+ \r
+ }\r
+ return null;\r
+ }\r
+\r
+ protected virtual void LoadViewState(object savedState)\r
+ {\r
+ if (savedState != null)\r
+ ViewState.LoadViewState (savedState);\r
+ }\r
+ \r
+ [MonoTODO]\r
+ protected string MapPathSecure(string virtualPath)\r
+ {\r
+ //TODO: Need to read up on security+web.\r
+ //Return the same path. So AdRotator can read its config file.\r
+ return virtualPath;\r
+ }\r
+ protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT\r
+ {\r
+ return false;\r
+ }\r
+ protected virtual void OnDataBinding(EventArgs e) //DIT\r
+ {\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[DataBindingEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ }\r
+ protected virtual void OnInit(EventArgs e) //DIT\r
+ {\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[InitEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ }\r
+ protected virtual void OnLoad(EventArgs e) //DIT\r
+ {\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[LoadEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ }\r
+ protected virtual void OnPreRender(EventArgs e) //DIT\r
+ {\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[PreRenderEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ }\r
+ protected virtual void OnUnload(EventArgs e) //DIT\r
+ {\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[UnloadEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ }\r
+ \r
+ [MonoTODO]\r
+ protected void RaiseBubbleEvent(object source, EventArgs args)\r
+ {\r
+ throw new NotImplementedException();\r
+ //return false;\r
+ }\r
+ protected virtual void Render(HtmlTextWriter writer) //DIT\r
+ {\r
+ RenderChildren(writer);\r
+ }\r
+ protected virtual void RenderChildren(HtmlTextWriter writer) //DIT\r
+ {\r
+ if (_renderMethodDelegate != null)\r
+ _renderMethodDelegate(writer, this);\r
+ else if (_controls != null)\r
+ foreach (Control c in _controls)\r
+ c.RenderControl(writer);\r
+ }\r
+ \r
+ protected virtual object SaveViewState ()\r
+ {\r
+ if (_viewState == null)\r
+ return null;\r
+\r
+ return _viewState.SaveViewState ();\r
+ }\r
+\r
+ protected virtual void TrackViewState()\r
+ {\r
+ if (_viewState != null)\r
+ _viewState.TrackViewState ();\r
+ _trackViewState = true;\r
+ }\r
+ \r
+ [MonoTODO]\r
+ public virtual void Dispose()\r
+ {\r
+ //TODO: nuke stuff.\r
+ throw new NotImplementedException();\r
+ /*\r
+ if (_events != null)\r
+ {\r
+ EventHandler eh = (EventHandler)(_events[DisposedEvent]);\r
+ if (eh != null) eh(this, e);\r
+ }\r
+ */\r
+ }\r
+\r
+ public bool HasChildren\r
+ {\r
+ get { return (_controls != null && _controls.Count > 0); }\r
+ }\r
+\r
+ public event EventHandler DataBinding //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(DataBindingEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(DataBindingEvent, value);\r
+ }\r
+ }\r
+ public event EventHandler Disposed //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(DisposedEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(DisposedEvent, value);\r
+ }\r
+ }\r
+ public event EventHandler Init //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(InitEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(InitEvent, value);\r
+ }\r
+ }\r
+ public event EventHandler Load //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(LoadEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(LoadEvent, value);\r
+ }\r
+ }\r
+ public event EventHandler PreRender //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(PreRenderEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(PreRenderEvent, value);\r
+ }\r
+ }\r
+ public event EventHandler Unload //DIT\r
+ {\r
+ add\r
+ {\r
+ Events.AddHandler(UnloadEvent, value);\r
+ }\r
+ remove\r
+ {\r
+ Events.RemoveHandler(UnloadEvent, value);\r
+ }\r
+ }\r
+ public virtual void DataBind() //DIT\r
+ {\r
+ OnDataBinding(EventArgs.Empty);\r
+ if (_controls != null)\r
+ foreach (Control c in _controls)\r
+ c.DataBind();\r
+ }\r
+ public virtual Control FindControl(string id) //DIT\r
+ {\r
+ return FindControl(id, 0);\r
+ }\r
+ public virtual bool HasControls() //DIT\r
+ {\r
+ if (_controls != null && _controls.Count >0) return true;\r
+ return false;\r
+ }\r
+ public void RenderControl(HtmlTextWriter writer)\r
+ {\r
+ if (_visible)\r
+ {\r
+ //TODO: Something about tracing here.\r
+ Render(writer);\r
+ }\r
+ }\r
+ \r
+ [MonoTODO]\r
+ public string ResolveUrl(string relativeUrl)\r
+ {\r
+ return relativeUrl;\r
+ }\r
+\r
+ public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT\r
+ {\r
+ _renderMethodDelegate = renderMethod;\r
+ }\r
+\r
+ protected void LoadRecursive()\r
+ {\r
+ OnLoad(EventArgs.Empty);\r
+ if (_controls != null) foreach (Control c in _controls) c.LoadRecursive();\r
+ }\r
+\r
+ protected void UnloadRecursive(Boolean dispose)\r
+ {\r
+ OnUnload(EventArgs.Empty);\r
+ if (_controls != null) foreach (Control c in _controls) c.UnloadRecursive(dispose);\r
+ if (dispose) Dispose();\r
+ }\r
+\r
+ protected void PreRenderRecursiveInternal()\r
+ {\r
+ OnPreRender(EventArgs.Empty);\r
+ if (_controls != null) foreach (Control c in _controls) c.PreRenderRecursiveInternal();\r
+ }\r
+\r
+ protected void InitRecursive(Control namingContainer)\r
+ {\r
+ if (_controls != null) foreach (Control c in _controls) c.InitRecursive(namingContainer);\r
+ OnInit(EventArgs.Empty);\r
+ TrackViewState ();\r
+ }\r
+ \r
+ protected object SaveViewStateRecursive()\r
+ {\r
+ if (!EnableViewState || !Visible)\r
+ return null;\r
+\r
+ ArrayList controlList = null;\r
+ ArrayList controlStates = null;\r
+\r
+ foreach (Control ctrl in Controls){\r
+ if (controlList == null) {\r
+ controlList = new ArrayList ();\r
+ controlStates = new ArrayList ();\r
+ }\r
+ controlList.Add (ctrl);\r
+ controlStates.Add (ctrl.SaveViewStateRecursive ());\r
+ }\r
+ \r
+ return new Triplet (SaveViewState (), controlList, controlStates);\r
+ }\r
+ \r
+ protected void LoadViewStateRecursive (object savedState)\r
+ {\r
+ if (!EnableViewState || !Visible || savedState == null)\r
+ return;\r
+\r
+ Triplet savedInfo = (Triplet) savedState;\r
+ LoadViewState (savedInfo.First);\r
+\r
+ ArrayList controlList = savedInfo.Second as ArrayList;\r
+ if (controlList == null)\r
+ return;\r
+ ArrayList controlStates = savedInfo.Third as ArrayList;\r
+ int nControls = controlList.Count;\r
+ for (int i = 0; i < nControls; i++) {\r
+ if (controlStates != null)\r
+ Controls [i].LoadViewStateRecursive (controlStates [i]);\r
+ }\r
+ }\r
+ \r
+ void IParserAccessor.AddParsedSubObject(object obj)\r
+ {\r
+ AddParsedSubObject(obj);\r
+ }\r
+ \r
+ DataBindingCollection IDataBindingsAccessor.DataBindings\r
+ {\r
+ get\r
+ {\r
+ if(dataBindings == null)\r
+ dataBindings = new DataBindingCollection();\r
+ return dataBindings;\r
+ }\r
+ }\r
+ \r
+ bool IDataBindingsAccessor.HasDataBindings\r
+ {\r
+ get\r
+ {\r
+ return (dataBindings!=null && dataBindings.Count>0);\r
+ }\r
+ }\r
+ \r
+ internal bool AutoID\r
+ {\r
+ get { return autoID; }\r
+ set { autoID = value; }\r
+ }\r
+\r
+ internal void PreventAutoID()\r
+ {\r
+ AutoID = false;\r
+ }\r
+ \r
+ protected internal virtual void RemovedControl (Control control)\r
+ {\r
+ control.UnloadRecursive (false);\r
+ control._parent = null;\r
+ control._page = null;\r
+ control._namingContainer = null;\r
+ }\r
+\r
+ //TODO: I think there are some needed Interface implementations to do here.\r
+ //TODO: Find api for INamingContainer.\r
+ }\r
+}\r