2 // System.Web.UI.WebControls.Label.cs
5 // Ben Maurer (bmaurer@novell.com)
7 // (C) 2005-2010 Novell, Inc (http://www.novell.com)
9 // TODO: Are we missing something in LoadViewState?
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 using System.ComponentModel;
32 using System.Security.Permissions;
34 namespace System.Web.UI.WebControls
37 [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
38 [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
40 [ControlBuilder(typeof(HyperLinkControlBuilder))]
41 [DataBindingHandler("System.Web.UI.Design.HyperLinkDataBindingHandler, " + Consts.AssemblySystem_Design)]
42 [ParseChildren (false)]
43 [ToolboxData("<{0}:HyperLink runat=\"server\">HyperLink</{0}:HyperLink>")]
44 [DefaultProperty("Text")]
45 [Designer("System.Web.UI.Design.WebControls.HyperLinkDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
46 public class HyperLink : WebControl
48 public HyperLink () : base (HtmlTextWriterTag.A)
52 protected override void AddAttributesToRender (HtmlTextWriter w)
54 base.AddAttributesToRender (w);
55 AddDisplayStyleAttribute (w);
58 // add attributes - only if they're not empty
60 string s = NavigateUrl;
62 w.AddAttribute (HtmlTextWriterAttribute.Href, ResolveClientUrl (s));
64 w.AddAttribute (HtmlTextWriterAttribute.Target, t);
67 protected override void AddParsedSubObject (object obj)
70 base.AddParsedSubObject (obj);
74 LiteralControl lc = obj as LiteralControl;
80 Controls.Add (new LiteralControl (s));
82 base.AddParsedSubObject (obj);
87 [MonoTODO ("Why override?")]
88 protected override void LoadViewState (object savedState)
90 base.LoadViewState (savedState);
93 protected internal override void RenderContents (HtmlTextWriter w)
95 if (HasControls () || HasRenderMethodDelegate ()) {
96 base.RenderContents (w);
99 string image_url = ImageUrl;
100 if (!String.IsNullOrEmpty (image_url)) {
101 string str = ToolTip;
102 if (!String.IsNullOrEmpty (str))
103 w.AddAttribute (HtmlTextWriterAttribute.Title, str);
105 w.AddAttribute (HtmlTextWriterAttribute.Src, ResolveClientUrl (image_url));
107 w.AddAttribute (HtmlTextWriterAttribute.Alt, str);
108 w.RenderBeginTag (HtmlTextWriterTag.Img);
116 [Editor("System.Web.UI.Design.ImageUrlEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
118 [WebSysDescription ("")]
119 [WebCategory ("Appearance")]
120 public virtual string ImageUrl {
121 get { return ViewState.GetString ("ImageUrl", String.Empty); }
122 set { ViewState ["ImageUrl"] = value; }
127 [Editor("System.Web.UI.Design.UrlEditor, " + Consts.AssemblySystem_Design, typeof(System.Drawing.Design.UITypeEditor))]
129 [WebSysDescription ("")]
130 [WebCategory ("Navigation")]
131 public string NavigateUrl {
132 get { return ViewState.GetString ("NavigateUrl", String.Empty); }
133 set { ViewState ["NavigateUrl"] = value; }
137 [TypeConverter(typeof(System.Web.UI.WebControls.TargetConverter))]
138 [WebSysDescription ("")]
139 [WebCategory ("Navigation")]
140 public string Target {
141 get { return ViewState.GetString ("Target", String.Empty); }
142 set { ViewState ["Target"] = value; }
147 [PersistenceMode(PersistenceMode.InnerDefaultProperty)]
149 [WebSysDescription ("")]
150 [WebCategory ("Appearance")]
151 public virtual string Text {
152 get { return ViewState.GetString ("Text", String.Empty); }
154 ViewState ["Text"] = value;
159 public override bool SupportsDisabledAttribute {
160 get { return RenderingCompatibilityLessThan40; }