New test.
[mono.git] / mcs / class / System.Web / System.Web.UI.WebControls / LinkButton.cs
index 52456d17a0f20084806e518a53be8ed89b13eef3..cda532a6fbadf7d749cfd6b52833bdb8f3b912e6 100644 (file)
@@ -63,6 +63,24 @@ namespace System.Web.UI.WebControls {
                        if (Page != null)
                                Page.VerifyRenderingInServerForm (this);
 
+#if NET_2_0
+                       string onclick = OnClientClick;
+                       onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick);
+                       if (Attributes ["onclick"] != null) {
+                               onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]);
+                               Attributes.Remove ("onclick");
+                       }
+
+                       if (onclick.Length > 0)
+                               w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
+
+                       if (Enabled && Page != null) {
+                               PostBackOptions options = GetPostBackOptions ();
+                               string href = Page.ClientScript.GetPostBackEventReference (options);
+                               w.AddAttribute (HtmlTextWriterAttribute.Href, href);
+                       }
+                       base.AddAttributesToRender (w);
+#else
                        base.AddAttributesToRender (w);
                        if (Page == null || !Enabled)
                                return;
@@ -75,17 +93,13 @@ namespace System.Web.UI.WebControls {
                        } else {
                                w.AddAttribute (HtmlTextWriterAttribute.Href, Page.ClientScript.GetPostBackClientHyperlink (this, ""));
                        }
+#endif
                }
 
 #if NET_2_0
-               [MonoTODO]
-               protected virtual void RaisePostBackEvent (string eventArgument)
-               {
-                       throw new NotImplementedException ();
-               }
+               protected virtual 
 #endif         
-               
-               void IPostBackEventHandler.RaisePostBackEvent (string ea)
+               void RaisePostBackEvent (string eventArgument)
                {
                        if (CausesValidation)
 #if NET_2_0
@@ -97,6 +111,11 @@ namespace System.Web.UI.WebControls {
                        OnClick (EventArgs.Empty);
                        OnCommand (new CommandEventArgs (CommandName, CommandArgument));
                }
+               
+               void IPostBackEventHandler.RaisePostBackEvent (string ea)
+               {
+                       RaisePostBackEvent (ea);
+               }
 
                protected override void AddParsedSubObject (object obj)
                {
@@ -122,9 +141,17 @@ namespace System.Web.UI.WebControls {
 #if NET_2_0
                protected virtual PostBackOptions GetPostBackOptions ()
                {
-                       return new PostBackOptions(this, PostBackUrl, null, false, true,
-                                                  false, true, CausesValidation,
-                                                  ValidationGroup);
+                       PostBackOptions options = new PostBackOptions (this);
+                       options.ActionUrl = (PostBackUrl.Length > 0 ? Page.ResolveClientUrl (PostBackUrl) : null);
+                       options.ValidationGroup = null;
+                       options.Argument = "";
+                       options.ClientSubmit = true;
+                       options.RequiresJavaScriptProtocol = true;
+                       options.PerformValidation = CausesValidation && Page != null && Page.AreValidatorsUplevel (ValidationGroup);
+                       if (options.PerformValidation)
+                               options.ValidationGroup = ValidationGroup;
+
+                       return options;
                }
 #endif         
 
@@ -220,16 +247,15 @@ namespace System.Web.UI.WebControls {
 #if NET_2_0
                [DefaultValue ("")]
                [Themeable (false)]
-               [MonoTODO]
                [WebSysDescription ("")]
                [WebCategoryAttribute ("Behavior")]
                public virtual string OnClientClick
                {
                        get {
-                               throw new NotImplementedException ();
+                               return ViewState.GetString ("OnClientClick", "");
                        }
                        set {
-                               throw new NotImplementedException ();
+                               ViewState ["OnClientClick"] = value;
                        }
                }