Control.cs 42 KB

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