Merge pull request #2448 from BrzVlad/feature-cprop-opt
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / Literal.cs
index c78b116087d5b10b03bc853e05e336477190d391..7e832dec6fdc69a984d16a42dbc04b5f98dc126e 100644 (file)
@@ -38,46 +38,36 @@ namespace System.Web.UI.WebControls {
        [ControlBuilder(typeof(LiteralControlBuilder))]
        [DataBindingHandler("System.Web.UI.Design.TextDataBindingHandler, " + Consts.AssemblySystem_Design)]
        [DefaultProperty("Text")]
-#if NET_2_0
        [Designer ("System.Web.UI.Design.WebControls.LiteralDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
-#endif         
        public class Literal : Control
-#if NET_2_0
        , ITextControl
-#endif 
        {
 
                public Literal ()
                {
                }
 
-#if NET_2_0
                [DefaultValue (LiteralMode.Transform)]
-               [MonoTODO]
                [WebSysDescription ("")]
                [WebCategory ("Behavior")]
                public LiteralMode Mode 
                {
                        get {
-                               throw new NotImplementedException ();
+                               return ViewState ["Mode"] == null ? LiteralMode.Transform : (LiteralMode) ViewState ["Mode"];
                        }
                        set {
-                               throw new NotImplementedException ();
+                               if (((int) value) < 0 || ((int) value) > 2)
+                                       throw new ArgumentOutOfRangeException ();
+                               ViewState ["Mode"] = value;
                        }
                }
-#endif         
 
                [Bindable(true)]
                [DefaultValue("")]
                [WebSysDescription ("")]
                [WebCategory ("Appearance")]
-#if NET_2_0
                [Localizable (true)]
-               public virtual
-#else          
-               public
-#endif         
-               string Text {
+               public string Text {
                        get {
                                return ViewState.GetString ("Text", String.Empty);
                        }
@@ -86,14 +76,11 @@ namespace System.Web.UI.WebControls {
                        }
                }
 
-#if NET_2_0
                [EditorBrowsable (EditorBrowsableState.Never)]
-               [MonoTODO]
                public override void Focus ()
                {
-                       throw new NotImplementedException ();
+                       throw new NotSupportedException ();
                }
-#endif         
 
                protected override ControlCollection CreateControlCollection ()
                {
@@ -113,13 +100,12 @@ namespace System.Web.UI.WebControls {
                              obj.GetType ()));
                }
 
-#if NET_2_0
                protected internal
-#else          
-               protected
-#endif         
                override void Render (HtmlTextWriter output)
                {
+                       if (Mode == LiteralMode.Encode)
+                               output.Write (HttpUtility.HtmlEncode (Text));
+                       else
                        output.Write (Text);
                }
        }