ValidationSummary.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: ValidationSummary
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: ??%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.Drawing;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. public class ValidationSummary : WebControl
  20. {
  21. private bool uplevelRender;
  22. public ValidationSummary(): base(HtmlTextWriterTag.Div)
  23. {
  24. uplevelRender = false;
  25. ForeColor = Color.Red;
  26. }
  27. public ValidationSummaryDisplayMode DisplayMode
  28. {
  29. get
  30. {
  31. object o = ViewState["DisplayMode"];
  32. if(o != null)
  33. return (ValidationSummaryDisplayMode)o;
  34. return ValidationSummaryDisplayMode.BulletList;
  35. }
  36. set
  37. {
  38. if(!Enum.IsDefined(typeof(ValidationSummaryDisplayMode), value))
  39. throw new ArgumentException();
  40. ViewState["DisplayMode"] = value;
  41. }
  42. }
  43. public bool EnableClientScript
  44. {
  45. get
  46. {
  47. object o = ViewState["EnableClientScript"];
  48. if(o != null)
  49. return (bool)o;
  50. return true;
  51. }
  52. set
  53. {
  54. ViewState["EnableClientScript"] = value;
  55. }
  56. }
  57. public override Color ForeColor
  58. {
  59. get
  60. {
  61. return ForeColor;
  62. }
  63. set
  64. {
  65. ForeColor = value;
  66. }
  67. }
  68. public bool ShowMessageBox
  69. {
  70. get
  71. {
  72. object o = ViewState["ShowMessageBox"];
  73. if(o != null)
  74. return (bool)o;
  75. return false;
  76. }
  77. set
  78. {
  79. ViewState["ShowMessageBox"] = value;
  80. }
  81. }
  82. public bool ShowSummary
  83. {
  84. get
  85. {
  86. object o = ViewState["ShowSummary"];
  87. if(o != null)
  88. return (bool)o;
  89. return true;
  90. }
  91. set
  92. {
  93. ViewState["ShowSummary"] = value;
  94. }
  95. }
  96. public string HeaderText
  97. {
  98. get
  99. {
  100. object o = ViewState["HeaderText"];
  101. if(o != null)
  102. return (string)o;
  103. return String.Empty;
  104. }
  105. set
  106. {
  107. ViewState["HeaderText"] = value;
  108. }
  109. }
  110. [MonoTODO("FIXME_See_Comments")]
  111. protected override void AddAttributesToRender(HtmlTextWriter writer)
  112. {
  113. AddAttributesToRender(writer);
  114. if(uplevelRender)
  115. {
  116. //FIXME: This is not the case always. I forgot the case when it is absent.
  117. // something to do with the ID's value? or ClienID's value itself?
  118. writer.AddAttribute("id", ClientID);
  119. if(HeaderText.Length > 0)
  120. writer.AddAttribute("headertext", HeaderText, true);
  121. if(ShowMessageBox)
  122. writer.AddAttribute("showmessagebox", "True");
  123. if(!ShowSummary)
  124. writer.AddAttribute("showsummary", "False");
  125. if(DisplayMode != ValidationSummaryDisplayMode.BulletList)
  126. {
  127. writer.AddAttribute("displaymode", PropertyConverter.EnumToString(typeof(ValidationSummaryDisplayMode), DisplayMode));
  128. }
  129. }
  130. }
  131. }
  132. }