Merge pull request #1155 from steffen-kiess/json-string
[mono.git] / mcs / class / System.Web / System.Web.UI.HtmlControls / HtmlInputButton.cs
index 534e2af36efb601a4b11cadd82e00bbadf3ce1c5..86aee3dd4156cb4082aa2b36363f1aad5a31f2b3 100644 (file)
@@ -225,13 +225,19 @@ namespace System.Web.UI.HtmlControls {
                                        onclick = ClientScriptManager.EnsureEndsWithSemicolon (Attributes ["onclick"] + onclick);
                                        Attributes.Remove ("onclick");
                                }
-                               if (Page != null) {
+
+                               Page page = Page;
+                               if (page != null) {
                                        PostBackOptions options = GetPostBackOptions ();
-                                       onclick += Page.ClientScript.GetPostBackEventReference (options, true);
+                                       onclick += page.ClientScript.GetPostBackEventReference (options, true);
                                }
 
                                if (onclick.Length > 0) {
-                                       writer.WriteAttribute ("onclick", onclick, true);
+                                       bool encode = true;
+                                       if (Events [ServerClickEvent] != null)
+                                               encode = false; // tests show that this is indeed
+                                                               // the case...
+                                       writer.WriteAttribute ("onclick", onclick, encode);
                                        writer.WriteAttribute ("language", "javascript");
                                }
                        }
@@ -247,13 +253,14 @@ namespace System.Web.UI.HtmlControls {
 
                PostBackOptions GetPostBackOptions ()
                {
+                       Page page = Page;
                        PostBackOptions options = new PostBackOptions (this);
                        options.ValidationGroup = null;
                        options.ActionUrl = null;
                        options.Argument = String.Empty;
                        options.RequiresJavaScriptProtocol = false;
                        options.ClientSubmit = (0 != String.Compare (Type, "submit", true, Helpers.InvariantCulture));
-                       options.PerformValidation = CausesValidation && Page != null && Page.Validators.Count > 0;
+                       options.PerformValidation = CausesValidation && page != null && page.Validators.Count > 0;
                        if (options.PerformValidation)
                                options.ValidationGroup = ValidationGroup;