New tests.
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlInputText.cs
index 4926dc61f9151b090dccc4f3392d95d240455a3a..cace1b4ef8c2fd932116a2415d17efa30e7e733f 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Sebastien Pouliot  <sebastien@ximian.com>
 //
-// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2005-2010 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -30,18 +30,17 @@ using System.ComponentModel;
 using System.Collections.Specialized;
 using System.Globalization;
 using System.Security.Permissions;
+using System.Web.Util;
 
-namespace System.Web.UI.HtmlControls {
-
+namespace System.Web.UI.HtmlControls
+{
        // CAS
        [AspNetHostingPermission (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [DefaultEvent ("ServerChange")]
        [ValidationProperty ("Value")]
-#if NET_2_0
        [SupportsEventValidation]
-#endif
        public class HtmlInputText : HtmlInputControl, IPostBackDataHandler 
        {
                static readonly object serverChangeEvent = new object ();
@@ -73,11 +72,7 @@ namespace System.Web.UI.HtmlControls {
                        }
                }
 
-#if NET_2_0
                [DefaultValue (-1)]
-#else
-               [DefaultValue ("")]
-#endif
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                [WebSysDescription("")]
                [WebCategory("Appearance")]
@@ -107,28 +102,22 @@ namespace System.Web.UI.HtmlControls {
                        }
                }
 
-
-#if NET_2_0
                protected internal override void Render (HtmlTextWriter writer)
                {
-                       Page.ClientScript.RegisterForEventValidation (UniqueID);
+                       Page page = Page;
+                       if (page != null)
+                               page.ClientScript.RegisterForEventValidation (UniqueID);
                        base.Render (writer);
                }
-#endif
 
-#if NET_2_0
-               protected internal
-#else          
-               protected
-#endif         
-               override void OnPreRender (EventArgs e)
+               protected internal override void OnPreRender (EventArgs e)
                {
                        base.OnPreRender (e);
-                       if (Page != null && !Disabled) {
-                               Page.RegisterRequiresPostBack (this);
-#if NET_2_0
-                               Page.RegisterEnabledControl (this);
-#endif
+
+                       Page page = Page;
+                       if (page != null && !Disabled) {
+                               page.RegisterRequiresPostBack (this);
+                               page.RegisterEnabledControl (this);
                        }
                }
 
@@ -142,7 +131,7 @@ namespace System.Web.UI.HtmlControls {
                protected override void RenderAttributes (HtmlTextWriter writer)
                {
                        // the Type property can be, indirectly, changed by using the Attributes property
-                       if (String.Compare (Type, 0, "password", 0, 8, true, CultureInfo.InvariantCulture) == 0) {
+                       if (String.Compare (Type, 0, "password", 0, 8, true, Helpers.InvariantCulture) == 0) {
                                Attributes.Remove ("value");
                        }
 
@@ -164,7 +153,6 @@ namespace System.Web.UI.HtmlControls {
                        OnServerChange (EventArgs.Empty);
                }
 
-#if NET_2_0
                protected virtual bool LoadPostData (string postDataKey, NameValueCollection postCollection)
                {
                        return LoadPostDataInternal (postDataKey, postCollection);
@@ -175,27 +163,17 @@ namespace System.Web.UI.HtmlControls {
                        ValidateEvent (UniqueID, String.Empty);
                        RaisePostDataChangedEventInternal ();
                }
-#endif
 
                bool IPostBackDataHandler.LoadPostData (string postDataKey, NameValueCollection postCollection)
                {
-#if NET_2_0
                        return LoadPostData (postDataKey, postCollection);
-#else
-                       return LoadPostDataInternal (postDataKey, postCollection);
-#endif
                }
 
                void IPostBackDataHandler.RaisePostDataChangedEvent ()
                {
-#if NET_2_0
                        RaisePostDataChangedEvent ();
-#else
-                       RaisePostDataChangedEventInternal ();
-#endif
                }
 
-
                [WebSysDescription("")]
                [WebCategory("Action")]
                public event EventHandler ServerChange {