WebControl.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: WebControl
  4. *
  5. * Author: Gaurav Vaish
  6. * Contact: <[email protected]>, <[email protected]>
  7. * Status: 15%??
  8. *
  9. * (C) Gaurav Vaish (2001)
  10. */
  11. using System;
  12. using System.Web;
  13. using System.Web.UI;
  14. using System.Drawing;
  15. using System.Collections.Specialized;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public class WebControl : Control, IAttributeAccessor
  19. {
  20. //TODO: A list of private members may be incomplete
  21. private HtmlTextWriterTag writerTag;
  22. private string stringTag;
  23. private AttributesCollection attributes;
  24. private StateBag attributeState;
  25. private Style controlStyle;
  26. // TODO: The constructors definitions
  27. protected WebControl()
  28. {
  29. //todo: what now?
  30. controlStyle = null;
  31. }
  32. public WebControl(HtmlTextWriterTag tag)
  33. {
  34. //TODO: am i right?
  35. writerTag = tag;
  36. stringTag = null;
  37. controlStyle = null;
  38. }
  39. protected WebControl(string tag)
  40. {
  41. //TODO: am i right?
  42. stringTag = tag;
  43. writerTag = null;
  44. controlStyle = null;
  45. }
  46. public virtual string AccessKey
  47. {
  48. get
  49. {
  50. object o = ViewState["AccessKey"];
  51. if(o!=null)
  52. return (string)o;
  53. return String.Empty;
  54. }
  55. set
  56. {
  57. ViewState["AccessKey"] = value;
  58. }
  59. }
  60. public AttributeCollection Attributes
  61. {
  62. if(attributes==null)
  63. {
  64. //TODO: From where to get StateBag and how? I think this method is OK!
  65. if(attributeState == null)
  66. {
  67. attributeState = new StateBag(true);
  68. if(attributeState.IsTrackingViewState)
  69. {
  70. attributeState.TrackViewState();
  71. }
  72. }
  73. attributes = new AttributeCollection(attributes);
  74. }
  75. return attributes;
  76. }
  77. public Style ControlStyle
  78. {
  79. get
  80. {
  81. if(controlStyle == null)
  82. {
  83. controlStyle = CreateControlStyle();
  84. if(IsTrackingViewState)
  85. {
  86. controlStyle.TrackViewState();
  87. }
  88. controlStyle.LoadViewState(null);
  89. }
  90. return controlStyle;
  91. }
  92. }
  93. public bool ControlStyleCreated
  94. {
  95. get
  96. {
  97. return (controlStyle!=null);
  98. }
  99. }
  100. public virtual string CssClass
  101. {
  102. get
  103. {
  104. if(ControlStyleCreated)
  105. return controlStyle.CssClass;
  106. return String.Empty;
  107. }
  108. }
  109. public
  110. protected virtual Style CreateControlStyle()
  111. {
  112. return new Style(ViewState); // from parent class Control
  113. }
  114. // Implemented procedures
  115. public string GetAttribute(string key)
  116. {
  117. return "";
  118. }
  119. public void SetAttribute(string key, string val)
  120. {
  121. }
  122. }
  123. }