Control.cs 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  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. if ((stateMask & IS_NAMING_CONTAINER) == 0)
  348. _namingContainer = NamingContainer;
  349. if (_namingContainer == null)
  350. return _userId;
  351. }
  352. if (_userId == null)
  353. _userId = _namingContainer.GetDefaultName ();
  354. string prefix = _namingContainer.UniqueID;
  355. if (_namingContainer == _page || prefix == null) {
  356. uniqueID = _userId;
  357. return uniqueID;
  358. }
  359. uniqueID = prefix + ":" + _userId;
  360. return uniqueID;
  361. }
  362. }
  363. void SetMask (int m, bool val)
  364. {
  365. if (val)
  366. stateMask |= m;
  367. else
  368. stateMask &= ~m;
  369. }
  370. [DefaultValue (true), Bindable (true), WebCategory ("Behavior")]
  371. [WebSysDescription ("Visiblity state of the control.")]
  372. public virtual bool Visible {
  373. get {
  374. if ((stateMask & VISIBLE) == 0)
  375. return false;
  376. if (_parent != null)
  377. return _parent.Visible;
  378. return true;
  379. }
  380. set {
  381. if ((value && (stateMask & VISIBLE) == 0) ||
  382. (!value && (stateMask & VISIBLE) != 0)) {
  383. if (IsTrackingViewState)
  384. stateMask |= VISIBLE_CHANGED;
  385. }
  386. SetMask (VISIBLE, value);
  387. }
  388. }
  389. protected bool ChildControlsCreated {
  390. get { return ((stateMask & CHILD_CONTROLS_CREATED) != 0); }
  391. set {
  392. if (value == false && (stateMask & CHILD_CONTROLS_CREATED) != 0)
  393. Controls.Clear();
  394. SetMask (CHILD_CONTROLS_CREATED, value);
  395. }
  396. }
  397. [Browsable (false)]
  398. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  399. protected virtual HttpContext Context //DIT
  400. {
  401. get
  402. {
  403. HttpContext context;
  404. if (_context != null)
  405. return _context;
  406. if (_parent == null)
  407. return HttpContext.Current;
  408. context = _parent.Context;
  409. if (context != null)
  410. return context;
  411. return HttpContext.Current;
  412. }
  413. }
  414. protected EventHandlerList Events {
  415. get {
  416. if (_events == null)
  417. _events = new EventHandlerList ();
  418. return _events;
  419. }
  420. }
  421. protected bool HasChildViewState {
  422. get {
  423. return (pendingVS != null && pendingVS.Count > 0);
  424. }
  425. }
  426. protected bool IsTrackingViewState {
  427. get { return ((stateMask & TRACK_VIEWSTATE) != 0); }
  428. }
  429. [Browsable (false)]
  430. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  431. [WebSysDescription ("ViewState")]
  432. protected virtual StateBag ViewState
  433. {
  434. get
  435. {
  436. if(_viewState == null)
  437. _viewState = new StateBag (ViewStateIgnoresCase);
  438. if (IsTrackingViewState)
  439. _viewState.TrackViewState ();
  440. return _viewState;
  441. }
  442. }
  443. [Browsable (false)]
  444. [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
  445. protected virtual bool ViewStateIgnoresCase
  446. {
  447. get {
  448. return false;
  449. }
  450. }
  451. internal bool AutoEventWireup {
  452. get { return (stateMask & AUTO_EVENT_WIREUP) != 0; }
  453. set { SetMask (AUTO_EVENT_WIREUP, value); }
  454. }
  455. internal void SetBindingContainer (bool isBC)
  456. {
  457. SetMask (BINDING_CONTAINER, isBC);
  458. }
  459. internal void ResetChildNames ()
  460. {
  461. defaultNumberID = 0;
  462. }
  463. string GetDefaultName ()
  464. {
  465. string defaultName;
  466. if (defaultNumberID > 99) {
  467. defaultName = "_ctl" + defaultNumberID++;
  468. } else {
  469. defaultName = defaultNameArray [defaultNumberID++];
  470. }
  471. return defaultName;
  472. }
  473. void NullifyUniqueID ()
  474. {
  475. uniqueID = null;
  476. if (!HasControls ())
  477. return;
  478. foreach (Control c in Controls)
  479. c.NullifyUniqueID ();
  480. }
  481. protected internal virtual void AddedControl (Control control, int index)
  482. {
  483. /* Ensure the control don't have more than 1 parent */
  484. if (control._parent != null)
  485. control._parent.Controls.Remove (control);
  486. control._parent = this;
  487. control._page = _page;
  488. Control nc = ((stateMask & IS_NAMING_CONTAINER) != 0) ? this : NamingContainer;
  489. if (nc != null) {
  490. control._namingContainer = nc;
  491. if (control.AutoID == true && control._userId == null)
  492. control._userId = nc.GetDefaultName ();
  493. }
  494. if ((stateMask & (INITING | INITED)) != 0)
  495. control.InitRecursive (nc);
  496. if ((stateMask & (VIEWSTATE_LOADED | LOADED)) != 0) {
  497. if (pendingVS != null) {
  498. object vs = pendingVS [index];
  499. if (vs != null) {
  500. pendingVS.Remove (index);
  501. if (pendingVS.Count == 0)
  502. pendingVS = null;
  503. control.LoadViewStateRecursive (vs);
  504. }
  505. }
  506. }
  507. if ((stateMask & LOADED) != 0)
  508. control.LoadRecursive ();
  509. if ((stateMask & PRERENDERED) != 0)
  510. control.PreRenderRecursiveInternal ();
  511. }
  512. protected virtual void AddParsedSubObject(object obj) //DIT
  513. {
  514. Control c = obj as Control;
  515. if (c != null) Controls.Add(c);
  516. }
  517. #if NET_2_0
  518. [EditorBrowsable (EditorBrowsableState.Advanced)]
  519. public virtual void ApplyStyleSheetSkin (Page page)
  520. {
  521. throw new NotImplementedException ();
  522. }
  523. #endif
  524. protected void BuildProfileTree(string parentId, bool calcViewState)
  525. {
  526. //TODO
  527. }
  528. #if NET_2_0
  529. protected void ClearChildControlState ()
  530. {
  531. throw new NotImplementedException ();
  532. }
  533. protected void ClearChildState ()
  534. {
  535. throw new NotImplementedException ();
  536. }
  537. #endif
  538. protected void ClearChildViewState ()
  539. {
  540. pendingVS = null;
  541. }
  542. #if NET_2_0
  543. protected internal
  544. #else
  545. protected
  546. #endif
  547. virtual void CreateChildControls() {} //DIT
  548. protected virtual ControlCollection CreateControlCollection() //DIT
  549. {
  550. return new ControlCollection(this);
  551. }
  552. protected virtual void EnsureChildControls ()
  553. {
  554. if (ChildControlsCreated == false && (stateMask & CREATING_CONTROLS) == 0) {
  555. stateMask |= CREATING_CONTROLS;
  556. #if NET_2_0
  557. if (Adapter != null)
  558. Adapter.CreateChildControls ();
  559. else
  560. #endif
  561. CreateChildControls();
  562. ChildControlsCreated = true;
  563. stateMask &= ~CREATING_CONTROLS;
  564. }
  565. }
  566. #if NET_2_0
  567. protected void EnsureID ()
  568. {
  569. throw new NotImplementedException ();
  570. }
  571. protected bool HasEvents ()
  572. {
  573. throw new NotImplementedException ();
  574. }
  575. #endif
  576. protected bool IsLiteralContent()
  577. {
  578. if (HasControls () && Controls.Count == 1 && (Controls [0] is LiteralControl))
  579. return true;
  580. return false;
  581. }
  582. [WebSysDescription ("")]
  583. public virtual Control FindControl (string id)
  584. {
  585. return FindControl (id, 0);
  586. }
  587. Control LookForControlByName (string id)
  588. {
  589. if (!HasControls ())
  590. return null;
  591. Control result = null;
  592. foreach (Control c in Controls) {
  593. if (String.Compare (id, c._userId, true) == 0) {
  594. if (result != null && result != c) {
  595. throw new HttpException ("1 Found more than one control with ID '" + id + "'");
  596. }
  597. result = c;
  598. continue;
  599. }
  600. if ((c.stateMask & IS_NAMING_CONTAINER) == 0 && c.HasControls ()) {
  601. Control child = c.LookForControlByName (id);
  602. if (child != null) {
  603. if (result != null && result != child)
  604. throw new HttpException ("2 Found more than one control with ID '" + id + "'");
  605. result = child;
  606. }
  607. }
  608. }
  609. return result;
  610. }
  611. protected virtual Control FindControl (string id, int pathOffset)
  612. {
  613. EnsureChildControls ();
  614. Control namingContainer = null;
  615. if ((stateMask & IS_NAMING_CONTAINER) == 0) {
  616. namingContainer = NamingContainer;
  617. if (namingContainer == null)
  618. return null;
  619. return namingContainer.FindControl (id, pathOffset);
  620. }
  621. if (!HasControls ())
  622. return null;
  623. int colon = id.IndexOf (':', pathOffset);
  624. if (colon == -1)
  625. return LookForControlByName (id.Substring (pathOffset));
  626. string idfound = id.Substring (pathOffset, colon - pathOffset);
  627. namingContainer = LookForControlByName (idfound);
  628. if (namingContainer == null)
  629. return null;
  630. return namingContainer.FindControl (id, colon + 1);
  631. }
  632. protected virtual void LoadViewState(object savedState)
  633. {
  634. if (savedState != null) {
  635. ViewState.LoadViewState (savedState);
  636. object o = ViewState ["Visible"];
  637. if (o != null) {
  638. SetMask (VISIBLE, (bool) o);
  639. stateMask |= VISIBLE_CHANGED;
  640. }
  641. }
  642. }
  643. [MonoTODO("Secure?")]
  644. protected string MapPathSecure(string virtualPath)
  645. {
  646. string combined = UrlUtils.Combine (TemplateSourceDirectory, virtualPath);
  647. return Context.Request.MapPath (combined);
  648. }
  649. protected virtual bool OnBubbleEvent(object source, EventArgs args) //DIT
  650. {
  651. #if MONO_TRACE
  652. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  653. string type_name = null;
  654. if (trace != null) {
  655. type_name = GetType ().Name;
  656. trace.Write ("control", String.Format ("OnBubbleEvent {0} {1}", _userId, type_name));
  657. }
  658. #endif
  659. return false;
  660. }
  661. protected virtual void OnDataBinding (EventArgs e)
  662. {
  663. if ((event_mask & databinding_mask) != 0) {
  664. EventHandler eh = (EventHandler)(_events [DataBindingEvent]);
  665. if (eh != null) {
  666. #if MONO_TRACE
  667. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  668. string type_name = null;
  669. if (trace != null) {
  670. type_name = GetType ().Name;
  671. trace.Write ("control", String.Format ("OnDataBinding {0} {1}", _userId, type_name));
  672. }
  673. #endif
  674. eh (this, e);
  675. }
  676. }
  677. }
  678. #if NET_2_0
  679. protected internal
  680. #else
  681. protected
  682. #endif
  683. virtual void OnInit (EventArgs e)
  684. {
  685. if ((event_mask & init_mask) != 0) {
  686. EventHandler eh = (EventHandler)(_events [InitEvent]);
  687. if (eh != null) {
  688. #if MONO_TRACE
  689. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  690. string type_name = null;
  691. if (trace != null) {
  692. type_name = GetType ().Name;
  693. trace.Write ("control", String.Format ("OnInit {0} {1}", _userId, type_name));
  694. }
  695. #endif
  696. eh (this, e);
  697. }
  698. }
  699. }
  700. #if NET_2_0
  701. protected internal
  702. #else
  703. protected
  704. #endif
  705. virtual void OnLoad (EventArgs e)
  706. {
  707. if ((event_mask & load_mask) != 0) {
  708. EventHandler eh = (EventHandler)(_events [LoadEvent]);
  709. if (eh != null) {
  710. #if MONO_TRACE
  711. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  712. string type_name = null;
  713. if (trace != null) {
  714. type_name = GetType ().Name;
  715. trace.Write ("control", String.Format ("OnLoad {0} {1}", _userId, type_name));
  716. }
  717. #endif
  718. eh (this, e);
  719. }
  720. }
  721. }
  722. #if NET_2_0
  723. protected internal
  724. #else
  725. protected
  726. #endif
  727. virtual void OnPreRender (EventArgs e)
  728. {
  729. if ((event_mask & prerender_mask) != 0) {
  730. EventHandler eh = (EventHandler)(_events [PreRenderEvent]);
  731. if (eh != null) {
  732. #if MONO_TRACE
  733. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  734. string type_name = null;
  735. if (trace != null) {
  736. type_name = GetType ().Name;
  737. trace.Write ("control", String.Format ("OnPreRender {0} {1}", _userId, type_name));
  738. }
  739. #endif
  740. eh (this, e);
  741. }
  742. }
  743. }
  744. #if NET_2_0
  745. protected internal
  746. #else
  747. protected
  748. #endif
  749. virtual void OnUnload(EventArgs e)
  750. {
  751. if ((event_mask & unload_mask) != 0) {
  752. EventHandler eh = (EventHandler)(_events [UnloadEvent]);
  753. if (eh != null) {
  754. #if MONO_TRACE
  755. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  756. string type_name = null;
  757. if (trace != null) {
  758. type_name = GetType ().Name;
  759. trace.Write ("control", String.Format ("OnUnload {0} {1}", _userId, type_name));
  760. }
  761. #endif
  762. eh (this, e);
  763. }
  764. }
  765. }
  766. #if NET_2_0
  767. protected internal Stream OpenFile (string path)
  768. {
  769. throw new NotImplementedException ();
  770. }
  771. #endif
  772. protected void RaiseBubbleEvent(object source, EventArgs args)
  773. {
  774. Control c = Parent;
  775. while (c != null) {
  776. #if MONO_TRACE
  777. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  778. string type_name = null;
  779. if (trace != null) {
  780. type_name = GetType ().Name;
  781. trace.Write ("control", String.Format ("RaiseBubbleEvent {0} {1}", _userId, type_name));
  782. }
  783. #endif
  784. if (c.OnBubbleEvent (source, args)) {
  785. #if MONO_TRACE
  786. if (trace != null)
  787. trace.Write ("control", String.Format ("End RaiseBubbleEvent (false) {0} {1}", _userId, type_name));
  788. #endif
  789. break;
  790. }
  791. #if MONO_TRACE
  792. if (trace != null)
  793. trace.Write ("control", String.Format ("End RaiseBubbleEvent (true) {0} {1}", _userId, type_name));
  794. #endif
  795. c = c.Parent;
  796. }
  797. }
  798. #if NET_2_0
  799. protected internal
  800. #else
  801. protected
  802. #endif
  803. virtual void Render(HtmlTextWriter writer) //DIT
  804. {
  805. RenderChildren(writer);
  806. }
  807. #if NET_2_0
  808. protected internal
  809. #else
  810. protected
  811. #endif
  812. virtual void RenderChildren (HtmlTextWriter writer) //DIT
  813. {
  814. if (_renderMethodDelegate != null) {
  815. _renderMethodDelegate (writer, this);
  816. } else if (_controls != null) {
  817. int len = _controls.Count;
  818. for (int i = 0; i < len; i++) {
  819. Control c = _controls [i];
  820. #if NET_2_0
  821. if (c.Adapter != null)
  822. c.RenderControl (writer, c.Adapter);
  823. else
  824. #endif
  825. c.RenderControl (writer);
  826. }
  827. }
  828. }
  829. #if NET_2_0
  830. protected virtual ControlAdapter ResolveAdapter ()
  831. {
  832. throw new NotImplementedException ();
  833. }
  834. #endif
  835. protected virtual object SaveViewState ()
  836. {
  837. if ((stateMask & VISIBLE_CHANGED) != 0) {
  838. ViewState ["Visible"] = (stateMask & VISIBLE) != 0;
  839. } else if (_viewState == null) {
  840. return null;
  841. }
  842. return _viewState.SaveViewState ();
  843. }
  844. protected virtual void TrackViewState()
  845. {
  846. if (_viewState != null)
  847. _viewState.TrackViewState ();
  848. stateMask |= TRACK_VIEWSTATE;
  849. }
  850. public virtual void Dispose ()
  851. {
  852. if ((event_mask & disposed_mask) != 0) {
  853. EventHandler eh = (EventHandler)(_events [DisposedEvent]);
  854. if (eh != null) eh (this, EventArgs.Empty);
  855. }
  856. }
  857. [WebCategory ("FIXME")]
  858. [WebSysDescription ("Raised when the contols databound properties are evaluated.")]
  859. public event EventHandler DataBinding {
  860. add {
  861. event_mask |= databinding_mask;
  862. Events.AddHandler (DataBindingEvent, value);
  863. }
  864. remove { Events.RemoveHandler (DataBindingEvent, value); }
  865. }
  866. [WebSysDescription ("Raised when the contol is disposed.")]
  867. public event EventHandler Disposed {
  868. add {
  869. event_mask |= disposed_mask;
  870. Events.AddHandler (DisposedEvent, value);
  871. }
  872. remove { Events.RemoveHandler (DisposedEvent, value); }
  873. }
  874. [WebSysDescription ("Raised when the page containing the control is initialized.")]
  875. public event EventHandler Init {
  876. add {
  877. event_mask |= init_mask;
  878. Events.AddHandler (InitEvent, value);
  879. }
  880. remove { Events.RemoveHandler (InitEvent, value); }
  881. }
  882. [WebSysDescription ("Raised after the page containing the control has been loaded.")]
  883. public event EventHandler Load {
  884. add {
  885. event_mask |= load_mask;
  886. Events.AddHandler (LoadEvent, value);
  887. }
  888. remove { Events.RemoveHandler (LoadEvent, value); }
  889. }
  890. [WebSysDescription ("Raised before the page containing the control is rendered.")]
  891. public event EventHandler PreRender {
  892. add {
  893. event_mask |= prerender_mask;
  894. Events.AddHandler (PreRenderEvent, value);
  895. }
  896. remove { Events.RemoveHandler (PreRenderEvent, value); }
  897. }
  898. [WebSysDescription ("Raised when the page containing the control is unloaded.")]
  899. public event EventHandler Unload {
  900. add {
  901. event_mask |= unload_mask;
  902. Events.AddHandler (UnloadEvent, value);
  903. }
  904. remove { Events.RemoveHandler (UnloadEvent, value); }
  905. }
  906. public virtual void DataBind() //DIT
  907. {
  908. #if NET_2_0
  909. DataBind (true);
  910. #else
  911. OnDataBinding (EventArgs.Empty);
  912. DataBindChildren();
  913. #endif
  914. }
  915. #if NET_2_0
  916. protected virtual
  917. #endif
  918. void DataBindChildren ()
  919. {
  920. if (!HasControls ())
  921. return;
  922. int len = Controls.Count;
  923. for (int i = 0; i < len; i++) {
  924. Control c = Controls [i];
  925. c.DataBind ();
  926. }
  927. }
  928. public virtual bool HasControls ()
  929. {
  930. return (_controls != null && _controls.Count > 0);
  931. }
  932. #if NET_2_0
  933. public virtual
  934. #else
  935. public
  936. #endif
  937. void RenderControl (HtmlTextWriter writer)
  938. {
  939. if ((stateMask & VISIBLE) != 0) {
  940. HttpContext ctx = Context;
  941. TraceContext trace = (ctx != null) ? ctx.Trace : null;
  942. int pos = 0;
  943. if ((trace != null) && trace.IsEnabled)
  944. pos = ctx.Response.GetOutputByteCount ();
  945. Render(writer);
  946. if ((trace != null) && trace.IsEnabled) {
  947. int size = ctx.Response.GetOutputByteCount () - pos;
  948. trace.SaveSize (this, size >= 0 ? size : 0);
  949. }
  950. }
  951. }
  952. #if NET_2_0
  953. protected void RenderControl (HtmlTextWriter writer,
  954. ControlAdapter adapter)
  955. {
  956. if ((stateMask & VISIBLE) != 0) {
  957. adapter.BeginRender (writer);
  958. adapter.Render (writer);
  959. adapter.EndRender (writer);
  960. }
  961. }
  962. #endif
  963. public string ResolveUrl (string relativeUrl)
  964. {
  965. if (relativeUrl == null)
  966. throw new ArgumentNullException ("relativeUrl");
  967. if (relativeUrl == "")
  968. return "";
  969. if (relativeUrl [0] == '#')
  970. return relativeUrl;
  971. string ts = TemplateSourceDirectory;
  972. if (ts == "" || !UrlUtils.IsRelativeUrl (relativeUrl))
  973. return relativeUrl;
  974. HttpResponse resp = Context.Response;
  975. return resp.ApplyAppPathModifier (UrlUtils.Combine (ts, relativeUrl));
  976. }
  977. internal bool HasRenderMethodDelegate () {
  978. return _renderMethodDelegate != null;
  979. }
  980. [EditorBrowsable (EditorBrowsableState.Advanced)]
  981. public void SetRenderMethodDelegate(RenderMethod renderMethod) //DIT
  982. {
  983. _renderMethodDelegate = renderMethod;
  984. }
  985. internal void LoadRecursive()
  986. {
  987. #if MONO_TRACE
  988. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  989. string type_name = null;
  990. if (trace != null) {
  991. type_name = GetType ().Name;
  992. trace.Write ("control", String.Format ("LoadRecursive {0} {1}", _userId, type_name));
  993. }
  994. #endif
  995. #if NET_2_0
  996. if (Adapter != null)
  997. Adapter.OnLoad (EventArgs.Empty);
  998. else
  999. #endif
  1000. OnLoad (EventArgs.Empty);
  1001. if (HasControls ()) {
  1002. int len = Controls.Count;
  1003. for (int i=0;i<len;i++)
  1004. {
  1005. Control c = Controls[i];
  1006. c.LoadRecursive ();
  1007. }
  1008. }
  1009. #if MONO_TRACE
  1010. if (trace != null)
  1011. trace.Write ("control", String.Format ("End LoadRecursive {0} {1}", _userId, type_name));
  1012. #endif
  1013. stateMask |= LOADED;
  1014. }
  1015. internal void UnloadRecursive(Boolean dispose)
  1016. {
  1017. #if MONO_TRACE
  1018. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  1019. string type_name = null;
  1020. if (trace != null) {
  1021. type_name = GetType ().Name;
  1022. trace.Write ("control", String.Format ("UnloadRecursive {0} {1}", _userId, type_name));
  1023. }
  1024. #endif
  1025. if (HasControls ()) {
  1026. int len = Controls.Count;
  1027. for (int i=0;i<len;i++)
  1028. {
  1029. Control c = Controls[i];
  1030. c.UnloadRecursive (dispose);
  1031. }
  1032. }
  1033. #if MONO_TRACE
  1034. if (trace != null)
  1035. trace.Write ("control", String.Format ("End UnloadRecursive {0} {1}", _userId, type_name));
  1036. #endif
  1037. #if NET_2_0
  1038. if (Adapter != null)
  1039. Adapter.OnUnload (EventArgs.Empty);
  1040. else
  1041. #endif
  1042. OnUnload (EventArgs.Empty);
  1043. if (dispose)
  1044. Dispose();
  1045. }
  1046. internal void PreRenderRecursiveInternal()
  1047. {
  1048. if ((stateMask & VISIBLE) != 0) {
  1049. EnsureChildControls ();
  1050. #if MONO_TRACE
  1051. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  1052. string type_name = null;
  1053. if (trace != null) {
  1054. type_name = GetType ().Name;
  1055. trace.Write ("control", String.Format ("PreRenderRecursive {0} {1}", _userId, type_name));
  1056. }
  1057. #endif
  1058. #if NET_2_0
  1059. if (Adapter != null)
  1060. Adapter.OnPreRender (EventArgs.Empty);
  1061. else
  1062. #endif
  1063. OnPreRender (EventArgs.Empty);
  1064. if (!HasControls ())
  1065. return;
  1066. int len = Controls.Count;
  1067. for (int i=0;i<len;i++)
  1068. {
  1069. Control c = Controls[i];
  1070. c.PreRenderRecursiveInternal ();
  1071. }
  1072. #if MONO_TRACE
  1073. if (trace != null)
  1074. trace.Write ("control", String.Format ("End PreRenderRecursive {0} {1}", _userId, type_name));
  1075. #endif
  1076. }
  1077. stateMask |= PRERENDERED;
  1078. }
  1079. internal void InitRecursive(Control namingContainer)
  1080. {
  1081. #if MONO_TRACE
  1082. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  1083. string type_name = null;
  1084. if (trace != null) {
  1085. type_name = GetType ().Name;
  1086. trace.Write ("control", String.Format ("InitRecursive {0} {1}", _userId, type_name));
  1087. }
  1088. #endif
  1089. if (HasControls ()) {
  1090. if ((stateMask & IS_NAMING_CONTAINER) != 0)
  1091. namingContainer = this;
  1092. if (namingContainer != null &&
  1093. namingContainer._userId == null &&
  1094. namingContainer.AutoID)
  1095. namingContainer._userId = namingContainer.GetDefaultName () + "b";
  1096. int len = Controls.Count;
  1097. for (int i=0;i<len;i++)
  1098. {
  1099. Control c = Controls[i];
  1100. c._page = Page;
  1101. c._namingContainer = namingContainer;
  1102. if (namingContainer != null && c._userId == null && c.AutoID)
  1103. c._userId = namingContainer.GetDefaultName () + "c";
  1104. c.InitRecursive (namingContainer);
  1105. }
  1106. }
  1107. stateMask |= INITING;
  1108. #if NET_2_0
  1109. if (Adapter != null)
  1110. Adapter.OnInit (EventArgs.Empty);
  1111. else
  1112. #endif
  1113. OnInit (EventArgs.Empty);
  1114. #if MONO_TRACE
  1115. if (trace != null)
  1116. trace.Write ("control", String.Format ("End InitRecursive {0} {1}", _userId, type_name));
  1117. #endif
  1118. TrackViewState ();
  1119. stateMask |= INITED;
  1120. stateMask &= ~INITING;
  1121. }
  1122. internal object SaveViewStateRecursive ()
  1123. {
  1124. if (!EnableViewState)
  1125. return null;
  1126. #if MONO_TRACE
  1127. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  1128. string type_name = null;
  1129. if (trace != null) {
  1130. type_name = GetType ().Name;
  1131. trace.Write ("control", String.Format ("SaveViewStateRecursive {0} {1}", _userId, type_name));
  1132. }
  1133. #endif
  1134. ArrayList controlList = null;
  1135. ArrayList controlStates = null;
  1136. int idx = -1;
  1137. if (HasControls ())
  1138. {
  1139. int len = Controls.Count;
  1140. for (int i=0;i<len;i++)
  1141. {
  1142. Control ctrl = Controls[i];
  1143. object ctrlState = ctrl.SaveViewStateRecursive ();
  1144. idx++;
  1145. if (ctrlState == null)
  1146. continue;
  1147. if (controlList == null)
  1148. {
  1149. controlList = new ArrayList ();
  1150. controlStates = new ArrayList ();
  1151. }
  1152. controlList.Add (idx);
  1153. controlStates.Add (ctrlState);
  1154. }
  1155. }
  1156. object thisState = SaveViewState ();
  1157. if (thisState == null && controlList == null && controlStates == null) {
  1158. #if MONO_TRACE
  1159. if (trace != null) {
  1160. trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved nothing", _userId, type_name));
  1161. trace.SaveViewState (this, null);
  1162. }
  1163. #endif
  1164. return null;
  1165. }
  1166. #if MONO_TRACE
  1167. if (trace != null) {
  1168. trace.Write ("control", String.Format ("End SaveViewStateRecursive {0} {1} saved a Triplet", _userId, type_name));
  1169. trace.SaveViewState (this, thisState);
  1170. }
  1171. #endif
  1172. return new Triplet (thisState, controlList, controlStates);
  1173. }
  1174. internal void LoadViewStateRecursive (object savedState)
  1175. {
  1176. if (!EnableViewState || savedState == null)
  1177. return;
  1178. #if MONO_TRACE
  1179. TraceContext trace = (Context != null && Context.Trace.IsEnabled) ? Context.Trace : null;
  1180. string type_name = null;
  1181. if (trace != null) {
  1182. type_name = GetType ().Name;
  1183. trace.Write ("control", String.Format ("LoadViewStateRecursive {0} {1}", _userId, type_name));
  1184. }
  1185. #endif
  1186. Triplet savedInfo = (Triplet) savedState;
  1187. LoadViewState (savedInfo.First);
  1188. ArrayList controlList = savedInfo.Second as ArrayList;
  1189. if (controlList == null)
  1190. return;
  1191. ArrayList controlStates = savedInfo.Third as ArrayList;
  1192. int nControls = controlList.Count;
  1193. for (int i = 0; i < nControls; i++) {
  1194. int k = (int) controlList [i];
  1195. if (k < Controls.Count && controlStates != null) {
  1196. Control c = Controls [k];
  1197. c.LoadViewStateRecursive (controlStates [i]);
  1198. } else {
  1199. if (pendingVS == null)
  1200. pendingVS = new Hashtable ();
  1201. pendingVS [k] = controlStates [i];
  1202. }
  1203. }
  1204. #if MONO_TRACE
  1205. if (trace != null)
  1206. trace.Write ("control", String.Format ("End LoadViewStateRecursive {0} {1}", _userId, type_name));
  1207. #endif
  1208. stateMask |= VIEWSTATE_LOADED;
  1209. }
  1210. internal bool AutoID
  1211. {
  1212. get { return (stateMask & AUTOID) != 0; }
  1213. set {
  1214. if (value == false && (stateMask & IS_NAMING_CONTAINER) != 0)
  1215. return;
  1216. SetMask (AUTOID, value);
  1217. }
  1218. }
  1219. protected internal virtual void RemovedControl (Control control)
  1220. {
  1221. control.UnloadRecursive (false);
  1222. control._parent = null;
  1223. control._page = null;
  1224. control._namingContainer = null;
  1225. }
  1226. #if NET_2_0
  1227. string skinId = string.Empty;
  1228. [Browsable (false)]
  1229. [Themeable (false)]
  1230. [DefaultValue (true)]
  1231. public virtual bool EnableTheming
  1232. {
  1233. get { return (stateMask & ENABLE_THEMING) != 0; }
  1234. set { SetMask (ENABLE_THEMING, value); }
  1235. }
  1236. [Browsable (false)]
  1237. [DefaultValue ("")]
  1238. [Filterable (false)]
  1239. public virtual string SkinID
  1240. {
  1241. get { return skinId; }
  1242. set { skinId = value; }
  1243. }
  1244. public string ResolveClientUrl (string url)
  1245. {
  1246. throw new NotImplementedException ();
  1247. }
  1248. ControlBuilder IControlBuilderAccessor.ControlBuilder {
  1249. get {throw new NotImplementedException (); }
  1250. }
  1251. IDictionary IControlDesignerAccessor.GetDesignModeState ()
  1252. {
  1253. throw new NotImplementedException ();
  1254. }
  1255. void IControlDesignerAccessor.SetDesignModeState (IDictionary designData)
  1256. {
  1257. SetDesignModeState (designData);
  1258. }
  1259. void IControlDesignerAccessor.SetOwnerControl (Control control)
  1260. {
  1261. throw new NotImplementedException ();
  1262. }
  1263. IDictionary IControlDesignerAccessor.UserData {
  1264. get { throw new NotImplementedException (); }
  1265. }
  1266. ExpressionBindingCollection expressionBindings;
  1267. ExpressionBindingCollection IExpressionsAccessor.Expressions {
  1268. get {
  1269. if (expressionBindings == null)
  1270. expressionBindings = new ExpressionBindingCollection ();
  1271. return expressionBindings;
  1272. }
  1273. }
  1274. bool IExpressionsAccessor.HasExpressions {
  1275. get {
  1276. return (expressionBindings != null && expressionBindings.Count > 0);
  1277. }
  1278. }
  1279. [MonoTODO]
  1280. public virtual void Focus()
  1281. {
  1282. throw new NotImplementedException();
  1283. }
  1284. protected internal virtual void LoadControlState (object state)
  1285. {
  1286. }
  1287. protected internal virtual object SaveControlState ()
  1288. {
  1289. return null;
  1290. }
  1291. protected virtual void DataBind (bool raiseOnDataBinding)
  1292. {
  1293. bool foundDataItem = false;
  1294. if ((stateMask & IS_NAMING_CONTAINER) != 0 && Page != null) {
  1295. object o = DataBinder.GetDataItem (this, out foundDataItem);
  1296. if (foundDataItem)
  1297. Page.PushDataItemContext (o);
  1298. }
  1299. try {
  1300. if (raiseOnDataBinding)
  1301. OnDataBinding (EventArgs.Empty);
  1302. DataBindChildren();
  1303. } finally {
  1304. if (foundDataItem)
  1305. Page.PopDataItemContext ();
  1306. }
  1307. }
  1308. protected virtual IDictionary GetDesignModeState ()
  1309. {
  1310. throw new NotImplementedException ();
  1311. }
  1312. protected virtual void SetDesignModeState (IDictionary data)
  1313. {
  1314. throw new NotImplementedException ();
  1315. }
  1316. #endif
  1317. void IParserAccessor.AddParsedSubObject (object obj) {
  1318. this.AddParsedSubObject (obj);
  1319. }
  1320. DataBindingCollection IDataBindingsAccessor.DataBindings {
  1321. get {
  1322. if (dataBindings == null) {
  1323. dataBindings = new DataBindingCollection ();
  1324. }
  1325. return dataBindings;
  1326. }
  1327. }
  1328. bool IDataBindingsAccessor.HasDataBindings {
  1329. get {
  1330. if (dataBindings != null && dataBindings.Count > 0) {
  1331. return true;
  1332. }
  1333. return false;
  1334. }
  1335. }
  1336. }
  1337. }