Merge branch 'master' of github.com:mono/mono
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlInputCheckBox.cs
index 23dd7345a2382b924be1016410531c4645134731..59eefc7a12f291657a069821fdf8480f86b5ed32 100644 (file)
@@ -4,7 +4,7 @@
 // Author:
 //     Dick Porter  <dick@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
@@ -37,11 +37,11 @@ namespace System.Web.UI.HtmlControls
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [DefaultEvent ("ServerChange")]
-#if NET_2_0
        [SupportsEventValidation]
-#endif
        public class HtmlInputCheckBox : HtmlInputControl, IPostBackDataHandler
        {
+               static readonly object EventServerChange = new object ();
+               
                public HtmlInputCheckBox () : base ("checkbox")
                {
                }
@@ -50,11 +50,8 @@ namespace System.Web.UI.HtmlControls
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                [WebSysDescription("")]
                [WebCategory("Misc")]
-#if NET_2_0
                [TypeConverter (typeof(MinimizableAttributeTypeConverter))]
-#endif
-               public bool Checked
-               {
+               public bool Checked {
                        get {
                                string check = Attributes["checked"];
 
@@ -72,13 +69,10 @@ namespace System.Web.UI.HtmlControls
                                }
                        }
                }
-               
-               private static readonly object EventServerChange = new object ();
 
                [WebSysDescription("")]
                [WebCategory("Action")]
-               public event EventHandler ServerChange
-               {
+               public event EventHandler ServerChange {
                        add {
                                Events.AddHandler (EventServerChange, value);
                        }
@@ -87,26 +81,22 @@ namespace System.Web.UI.HtmlControls
                        }
                }
 
-#if NET_2_0
                protected override void RenderAttributes (HtmlTextWriter writer)
                {
-                       if (Page != null)
-                               Page.ClientScript.RegisterForEventValidation (this.UniqueID);
+                       Page page = Page;
+                       if (page != null)
+                               page.ClientScript.RegisterForEventValidation (UniqueID);
                        base.RenderAttributes (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) {
-                               Page.RegisterRequiresPostBack (this);
+                       Page page = Page;
+                       if (page != null && !Disabled) {
+                               page.RegisterRequiresPostBack (this);
+                               page.RegisterEnabledControl (this);
                        }
                }
 
@@ -114,9 +104,8 @@ namespace System.Web.UI.HtmlControls
                {
                        EventHandler handler = (EventHandler)Events[EventServerChange];
 
-                       if (handler != null) {
+                       if (handler != null)
                                handler (this, e);
-                       }
                }
 
                bool LoadPostDataInternal (string postDataKey, NameValueCollection postCollection)
@@ -138,7 +127,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);
@@ -146,26 +134,18 @@ namespace System.Web.UI.HtmlControls
 
                protected virtual void RaisePostDataChangedEvent ()
                {
+                       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
                }
        }
 }