New test.
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlInputImage.cs
index 6755b2e395f64f18c5e996e085fcf73479034a99..9e441310ab7ca4c704d2ea32d1625cbde2c99a56 100644 (file)
@@ -43,6 +43,9 @@ namespace System.Web.UI.HtmlControls {
        [AspNetHostingPermission (SecurityAction.InheritanceDemand, Level = AspNetHostingPermissionLevel.Minimal)]
        // attributes
        [DefaultEvent("ServerClick")]
+#if NET_2_0
+       [SupportsEventValidation]
+#endif
        public class HtmlInputImage : HtmlInputControl, IPostBackDataHandler,
                      IPostBackEventHandler {
 
@@ -97,6 +100,9 @@ namespace System.Web.UI.HtmlControls {
                [WebSysDescription("")]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
                [WebCategory("Appearance")]
+#if NET_2_0
+               [UrlProperty]
+#endif
                public string Src {
                        get { return GetAtt ("src"); }
                        set { SetAtt ("src", value); }
@@ -161,7 +167,7 @@ namespace System.Web.UI.HtmlControls {
 
 #if NET_2_0
                [DefaultValue ("")]
-               public string ValidationGroup
+               public virtual string ValidationGroup
                {
                        get {
                                return ViewState.GetString ("ValidationGroup", "");
@@ -239,17 +245,27 @@ namespace System.Web.UI.HtmlControls {
 
                protected override void RenderAttributes (HtmlTextWriter writer)
                {
+#if NET_2_0
+                       if (Page != null)
+                               Page.ClientScript.RegisterForEventValidation (this.UniqueID);
+                       
+                       if (CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup)) {
+                               ClientScriptManager csm = Page.ClientScript;
+                               Attributes ["onclick"] += csm.GetClientValidationEvent (ValidationGroup);
+                       }
+#else          
                        if (CausesValidation && Page != null && Page.AreValidatorsUplevel ()) {
                                ClientScriptManager csm = new ClientScriptManager (Page);
                                writer.WriteAttribute ("onclick", csm.GetClientValidationEvent ());
                        }
+#endif         
 
                        base.RenderAttributes (writer);
                }
 
                private void SetAtt (string name, string value)
                {
-                       if (value == null)
+                       if ((value == null) || (value.Length == 0))
                                Attributes.Remove (name);
                        else
                                Attributes [name] = value;