Image.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * Namespace: System.Web.UI.WebControls
  3. * Class: Image
  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 (2001)
  12. */
  13. using System;
  14. using System.Web;
  15. using System.Web.UI;
  16. namespace System.Web.UI.WebControls
  17. {
  18. public class Image : WebControl
  19. {
  20. public Image(): base(HtmlTextWriterTag.Img)
  21. {
  22. }
  23. public virtual string AlternateText
  24. {
  25. get
  26. {
  27. object o = ViewState["AlternateText"];
  28. if(o!=null)
  29. return (string)o;
  30. return String.Empty;
  31. }
  32. set
  33. {
  34. ViewState["AlternateText"] = value;
  35. }
  36. }
  37. public override bool Enabled
  38. {
  39. get
  40. {
  41. return base.Enabled;
  42. }
  43. set
  44. {
  45. base.Enabled = value;
  46. }
  47. }
  48. public override FontInfo Font
  49. {
  50. get
  51. {
  52. return base.Font;
  53. }
  54. }
  55. public virtual ImageAlign ImageAlign
  56. {
  57. get
  58. {
  59. object o = ViewState["ImageAlign"];
  60. if(o!=null)
  61. return (ImageAlign)o;
  62. return ImageAlign.NotSet;
  63. }
  64. set
  65. {
  66. ViewState["ImageAlign"] = value;
  67. }
  68. }
  69. public virtual string ImageUrl
  70. {
  71. get
  72. {
  73. object o = ViewState["ImageUrl"];
  74. if(o!=null)
  75. return (string)o;
  76. return String.Empty;
  77. }
  78. set
  79. {
  80. ViewState["ImageUrl"] = value;
  81. }
  82. }
  83. protected override void AddAttributesToRender(HtmlTextWriter writer)
  84. {
  85. AddAttributesToRender(writer);
  86. if(ImageUrl.Length > 0)
  87. {
  88. writer.AddAttribute(HtmlTextWriterAttribute.Src, ResolveUrl(ImageUrl));
  89. }
  90. if(AlternateText.Length > 0)
  91. {
  92. writer.AddAttribute(HtmlTextWriterAttribute.Alt, AlternateText);
  93. }
  94. if(BorderWidth.IsEmpty)
  95. {
  96. writer.AddAttribute(HtmlTextWriterAttribute.Border, "0");
  97. }
  98. if(ImageAlign != ImageAlign.NotSet)
  99. {
  100. writer.AddAttribute(HtmlTextWriterAttribute.Align, Enum.Format(typeof(ImageAlign), ImageAlign, "G"));
  101. }
  102. }
  103. protected override void RenderContents(HtmlTextWriter writer)
  104. {
  105. }
  106. }
  107. }