2 // System.Web.UI.WebControls.Literal.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
14 using System.Web.UI;
\r
15 using System.ComponentModel;
\r
17 namespace System.Web.UI.WebControls
\r
19 [DefaultProperty("Text")]
\r
20 [ControlBuilder(typeof(LiteralControlBuilder))]
\r
21 [DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + Consts.AssemblySystem_Design)]
\r
22 public class Literal : Control
\r
24 public Literal () : base ()
\r
28 [DefaultValue (""), Bindable (true), WebCategory ("Appearance")]
29 [WebSysDescription ("The text for the literal WebControl.")]
\r
33 object o = ViewState ["Text"];
\r
34 return (o == null) ? String.Empty : (string) o;
\r
37 set { ViewState ["Text"] = value; }
\r
40 protected override ControlCollection CreateControlCollection ()
\r
42 return new EmptyControlCollection (this);
\r
45 protected override void AddParsedSubObject (object obj)
\r
47 if (!(obj is LiteralControl))
\r
48 throw new HttpException (HttpRuntime.FormatResourceString (
\r
49 "Cannot_Have_Children_Of_Type", "Literal",
\r
50 obj.GetType ().Name.ToString ()));
\r
52 Text = ((LiteralControl) obj).Text;
\r
55 protected override void Render (HtmlTextWriter writer)
\r
57 if (Text.Length > 0)
\r
58 writer.Write (Text);
\r