fixed: when removed the names from the bag also removed FontStyles.Names flag from...
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / ImageButton.cs
index 0a473f044939d737e48f3f8fe423ee3fd13a5763..022617e18d2902ce61ae41759b751456d4f520e9 100644 (file)
 
 using System.Collections.Specialized;
 using System.ComponentModel;
+using System.Security.Permissions;
 
 namespace System.Web.UI.WebControls {
+
+       // CAS
+       [AspNetHostingPermissionAttribute (SecurityAction.LinkDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       [AspNetHostingPermissionAttribute (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
+       // attributes
        [DefaultEvent("Click")]
 #if NET_2_0
        [Designer ("System.Web.UI.Design.WebControls.PreviewControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
-#endif         
-       public class ImageButton : Image, IPostBackDataHandler, IPostBackEventHandler
-#if NET_2_0
-       , IButtonControl
-#endif 
-       {
-
+       [SupportsEventValidation]
+       public class ImageButton : Image, IPostBackDataHandler, IPostBackEventHandler, IButtonControl {
+#else
+       public class ImageButton : Image, IPostBackDataHandler, IPostBackEventHandler {
+#endif
                private static readonly object ClickEvent = new object ();
                private static readonly object CommandEvent = new object ();
                private int pos_x, pos_y;
@@ -79,11 +83,8 @@ namespace System.Web.UI.WebControls {
                [WebCategory ("Behavior")]
 #if NET_2_0
                [Themeable (false)]
-               public virtual
-#else          
-               public
 #endif         
-               string CommandArgument {
+               public string CommandArgument {
                        get {
                                return ViewState.GetString ("CommandArgument", "");
                        }
@@ -97,11 +98,8 @@ namespace System.Web.UI.WebControls {
                [WebCategory ("Behavior")]
 #if NET_2_0
                [Themeable (false)]
-               public virtual
-#else          
-               public
 #endif         
-               string CommandName {
+               public string CommandName {
                        get {
                                return ViewState.GetString ("CommandName", "");
                        }
@@ -162,14 +160,12 @@ namespace System.Web.UI.WebControls {
 #endif
                [DefaultValue ("")]
                [Editor ("System.Web.UI.Design.UrlEditor, "  + Consts.AssemblySystem_Design, "System.Drawing.Design.UITypeEditor, " + Consts.AssemblySystem_Drawing)]
-               [MonoTODO]
-               public virtual string PostBackUrl
-               {
+               public virtual string PostBackUrl {
                        get {
-                               throw new NotImplementedException ();
+                               return ViewState.GetString ("PostBackUrl", String.Empty);
                        }
                        set {
-                               throw new NotImplementedException ();
+                               ViewState["PostBackUrl"] = value;
                        }
                }
 
@@ -218,6 +214,7 @@ namespace System.Web.UI.WebControls {
                                Page.VerifyRenderingInServerForm (this);
 
                        writer.AddAttribute (HtmlTextWriterAttribute.Type, "image");
+                       writer.AddAttribute (HtmlTextWriterAttribute.Name, UniqueID);
                        if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
                                ClientScriptManager csm = new ClientScriptManager (Page);
                                writer.AddAttribute (HtmlTextWriterAttribute.Onclick, csm.GetClientValidationEvent ());
@@ -227,10 +224,11 @@ namespace System.Web.UI.WebControls {
                }
 
 #if NET_2_0
-               [MonoTODO]
                protected virtual PostBackOptions GetPostBackOptions ()
                {
-                       throw new NotImplementedException ();
+                       return new PostBackOptions(this, PostBackUrl, null, false, true,
+                                                  false, true, CausesValidation,
+                                                  ValidationGroup);
                }
 #endif         
 
@@ -241,17 +239,25 @@ namespace System.Web.UI.WebControls {
                bool LoadPostData (string postDataKey, NameValueCollection postCollection) 
                {
                        string x, y;
-
-                       x = postCollection [UniqueID + ".x"];
-                       y = postCollection [UniqueID + ".y"];
-
-                       if (x != null && y != null) {
+                       string unique = UniqueID;
+                       x = postCollection [unique + ".x"];
+                       y = postCollection [unique + ".y"];
+                       if (x != null && x != "" && y != null && y != "") {
                                pos_x = Int32.Parse(x);
                                pos_y = Int32.Parse(y);
                                Page.RegisterRequiresRaiseEvent (this);
+                               return true;
+                       } else {
+                               x = postCollection [unique];
+                               if (x != null && x != "") {
+                                       pos_x = Int32.Parse (x);
+                                       pos_y = 0;
+                                       Page.RegisterRequiresRaiseEvent (this);
+                                       return true;
+                               }
                        }
 
-                       return true;
+                       return false;
                }
 #if NET_2_0
                protected virtual