2 // System.Web.UI.WebControls.Image.cs
5 // Gaurav Vaish (gvaish@iitk.ac.in)
6 // Andreas Nahr (ClassDevelopment@A-SoftTech.com)
8 // (C) Gaurav Vaish (2002)
9 // (C) 2003 Andreas Nahr
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 using System
.ComponentModel
;
38 namespace System
.Web
.UI
.WebControls
40 [DefaultProperty("ImageUrl")]
41 public class Image
: WebControl
43 public Image(): base(HtmlTextWriterTag
.Img
)
47 [DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
48 [WebSysDescription ("An alternative text that is shown if the image cannot be displayed.")]
49 public virtual string AlternateText
53 object o
= ViewState
["AlternateText"];
60 ViewState
["AlternateText"] = value;
64 [Browsable (false), EditorBrowsable (EditorBrowsableState
.Never
)]
65 public override bool Enabled
77 [Browsable (false), EditorBrowsable (EditorBrowsableState
.Never
)]
78 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
79 public override FontInfo Font
87 [DefaultValue (typeof (ImageAlign
), "NotSet"), Bindable (true), WebCategory ("Layout")]
88 [WebSysDescription ("The alignment of the image.")]
89 public virtual ImageAlign ImageAlign
93 object o
= ViewState
["ImageAlign"];
96 return ImageAlign
.NotSet
;
100 ViewState
["ImageAlign"] = value;
104 [DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
105 [Editor ("System.Web.UI.Design.ImageUrlEditor, " + Consts
.AssemblySystem_Design
, typeof (System
.Drawing
.Design
.UITypeEditor
))]
106 [WebSysDescription ("The URL to the image file.")]
107 public virtual string ImageUrl
111 object o
= ViewState
["ImageUrl"];
118 ViewState
["ImageUrl"] = value;
122 protected override void AddAttributesToRender(HtmlTextWriter writer
)
124 base.AddAttributesToRender(writer
);
125 if(ImageUrl
.Length
> 0)
127 writer
.AddAttribute(HtmlTextWriterAttribute
.Src
, ResolveUrl(ImageUrl
));
129 if(AlternateText
.Length
> 0)
131 writer
.AddAttribute(HtmlTextWriterAttribute
.Alt
, AlternateText
);
133 if(BorderWidth
.IsEmpty
)
135 writer
.AddAttribute(HtmlTextWriterAttribute
.Border
, "0");
137 if(ImageAlign
!= ImageAlign
.NotSet
)
139 writer
.AddAttribute(HtmlTextWriterAttribute
.Align
, Enum
.Format(typeof(ImageAlign
), ImageAlign
, "G"));
143 protected override void RenderContents(HtmlTextWriter writer
)