2008-10-24 Marek Habersack <mhabersack@novell.com>
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlInputHidden.cs
index dddb2a738d9aa1b7e2f0b6503edcca002b9b99bf..755ce95b9bcc2969e0bbe1b223012adc0618c5f5 100644 (file)
@@ -37,9 +37,12 @@ namespace System.Web.UI.HtmlControls {
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [DefaultEvent ("ServerChange")]
+#if NET_2_0
+       [SupportsEventValidation]
+#endif
        public class HtmlInputHidden : HtmlInputControl, IPostBackDataHandler {
 
-               private static readonly object ServerChangeEvent = new object ();
+               static readonly object ServerChangeEvent = new object ();
 
                public HtmlInputHidden () : base ("hidden")
                {
@@ -49,6 +52,9 @@ namespace System.Web.UI.HtmlControls {
                {
                        string data = postCollection [postDataKey];
                        if (data != null && data != Value) {
+#if NET_2_0
+                               ValidateEvent (postDataKey, String.Empty);
+#endif
                                Value = data;
                                return true;
                        }
@@ -75,15 +81,31 @@ namespace System.Web.UI.HtmlControls {
                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
                }
 
 #if NET_2_0
+               protected override void RenderAttributes (HtmlTextWriter writer)
+               {
+                       Page page = Page;
+                       if (page != null)
+                               page.ClientScript.RegisterForEventValidation (Name);
+                       base.RenderAttributes (writer);
+               }               
+
                protected internal
 #else
                protected
@@ -91,6 +113,13 @@ namespace System.Web.UI.HtmlControls {
                override void OnPreRender (EventArgs e)
                {
                        base.OnPreRender (e);
+
+                       if (Page != null && !Disabled) {
+                               Page.RegisterRequiresPostBack (this);
+#if NET_2_0
+                               Page.RegisterEnabledControl (this);
+#endif
+                       }
                }
 
                protected virtual void OnServerChange (EventArgs e)