CheckBox.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: CheckBox
  4. *
  5. * Author: Gaurav Vaish
  6. * Contact: <[email protected]>, <[email protected]>
  7. * Status: 60%
  8. *
  9. * (C) Gaurav Vaish (2001)
  10. */
  11. using System;
  12. using System.Collections;
  13. using System.Collections.Specialized;
  14. using System.Web;
  15. using System.Web.UI;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public class CheckBox : WebControl, IPostBackDataHandler
  19. {
  20. private static readonly object CheckedChangedEvent = new object();
  21. public CheckBox()
  22. {
  23. //
  24. }
  25. public virtual bool AutoPostBack
  26. {
  27. get
  28. {
  29. object o = ViewState["AutoPostBack"];
  30. if(o!=null)
  31. return (bool)AutoPostBack;
  32. return false;
  33. }
  34. set
  35. {
  36. ViewState["AutoPostBack"] = value;
  37. }
  38. }
  39. public virtual bool Checked
  40. {
  41. get
  42. {
  43. object o = ViewState["Checked"];
  44. if(o!=null)
  45. return (bool)o;
  46. return false;
  47. }
  48. set
  49. {
  50. ViewState["Checked"] = value;
  51. }
  52. }
  53. public virtual string Text
  54. {
  55. get
  56. {
  57. object o = ViewState["Text"];
  58. if(o!=null)
  59. return (string)o;
  60. return String.Empty;
  61. }
  62. set
  63. {
  64. ViewState["Text"] = value;
  65. }
  66. }
  67. public virtual TextAlign TextAlign
  68. {
  69. get
  70. {
  71. object o = ViewState["TextAlign"];
  72. if(o!=null)
  73. return (TextAlign)o;
  74. return TextAlign.Right;
  75. }
  76. set
  77. {
  78. if(!System.Enum.IsDefined(typeof(TextAlign), value))
  79. throw new ArgumentException();
  80. ViewState["TextAlign"] = value;
  81. }
  82. }
  83. public event EventHandler CheckedChanged
  84. {
  85. add
  86. {
  87. Events.AddHandler(CheckedChangedEvent, value);
  88. }
  89. remove
  90. {
  91. Events.RemoveHandler(CheckedChangedEvent, value);
  92. }
  93. }
  94. protected virtual void OnCheckedChanged(EventArgs e)
  95. {
  96. if(Events!=null)
  97. {
  98. EventHandler eh = (EventHandler)(Events[CheckedChangedEvent]);
  99. if(eh!=null)
  100. eh(this, e);
  101. }
  102. }
  103. protected override void Render(HtmlTextWriter writer)
  104. {
  105. //TODO: THE LOST WORLD!
  106. // I know I have to do it.
  107. }
  108. public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
  109. {
  110. //TODO: THE LOST WORLD
  111. // Now what the hell is this!
  112. return false;
  113. }
  114. public void RaisePostDataChangedEvent()
  115. {
  116. //TODO: THE LOST WORLD...
  117. // Raise the bucket out of the well :))
  118. OnCheckedChanged(EventArgs.Empty);
  119. }
  120. }
  121. }