Panel.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: Panel
  4. *
  5. * Author: Gaurav Vaish
  6. * Maintainer: [email protected]
  7. * Contact: <[email protected]>, <[email protected]>
  8. * Implementation: yes
  9. * Status: 100%
  10. *
  11. * (C) Gaurav Vaish (2002)
  12. */
  13. using System;
  14. using System.ComponentModel;
  15. using System.Web;
  16. using System.Web.UI;
  17. namespace System.Web.UI.WebControls
  18. {
  19. //[Designer("??")]
  20. [ParseChildren(false)]
  21. [PersistChildren(true)]
  22. [ToolboxData("<{0}:Panel runat=\"server\">Panel</{0}:Panel>")]
  23. public class Panel: WebControl
  24. {
  25. public Panel(): base(HtmlTextWriterTag.Div)
  26. {
  27. }
  28. public virtual string BackImageUrl
  29. {
  30. get
  31. {
  32. object o = ViewState["BackImageUrl"];
  33. if(o != null)
  34. return (string)o;
  35. return String.Empty;
  36. }
  37. set
  38. {
  39. ViewState["BackImageUrl"] = value;
  40. }
  41. }
  42. public virtual HorizontalAlign HorizontalAlign
  43. {
  44. get
  45. {
  46. object o = ViewState["HorizontalAlign"];
  47. if(o != null)
  48. return (HorizontalAlign)o;
  49. return HorizontalAlign.NotSet;
  50. }
  51. set
  52. {
  53. if(!Enum.IsDefined(typeof(HorizontalAlign), value))
  54. {
  55. throw new ArgumentException();
  56. }
  57. ViewState["HorizontalAlign"] = value;
  58. }
  59. }
  60. public virtual bool Wrap
  61. {
  62. get
  63. {
  64. object o = ViewState["Wrap"];
  65. if(o != null)
  66. return (bool)o;
  67. return true;
  68. }
  69. set
  70. {
  71. ViewState["Wrap"] = value;
  72. }
  73. }
  74. protected override void AddAttributesToRender(HtmlTextWriter writer)
  75. {
  76. AddAttributesToRender(writer);
  77. if(BackImageUrl.Length > 0)
  78. {
  79. writer.AddStyleAttribute(HtmlTextWriterStyle.BackgroundImage, "url(" + ResolveUrl(BackImageUrl) + ")");
  80. }
  81. if(HorizontalAlign != HorizontalAlign.NotSet)
  82. {
  83. writer.AddAttribute(HtmlTextWriterAttribute.Align, TypeDescriptor.GetConverter(typeof(HorizontalAlign)).ConvertToString(HorizontalAlign));
  84. }
  85. if(Wrap)
  86. {
  87. writer.AddAttribute(HtmlTextWriterAttribute.Nowrap, "nowrap");
  88. }
  89. }
  90. }
  91. }