Merge pull request #853 from echampet/onclick
authorMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2015 19:00:41 +0000 (15:00 -0400)
committerMiguel de Icaza <miguel@gnome.org>
Wed, 23 Sep 2015 19:00:41 +0000 (15:00 -0400)
[FIX] correctly handle custom onclick attribute when autopostback = true...

1  2 
mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs

index 905740a1ea9d9f4d4e896cadb7e7ceaa1e177f25,e57c5969d32775776adb2991644719751080dddc..27c3a7fb9dc870f7018c9a6956ef0871173ecb54
@@@ -315,9 -315,11 +315,9 @@@ namespace System.Web.UI.WebControl
                        bool need_span = ControlStyleCreated && !ControlStyle.IsEmpty;
                        bool enabled = IsEnabled;
                        if (!enabled) {
 -#if NET_4_0
                                if (!RenderingCompatibilityLessThan40)
                                        ControlStyle.PrependCssClass (DisabledCssClass);
                                else
 -#endif
                                        w.AddAttribute (HtmlTextWriterAttribute.Disabled, "disabled", false);
                                need_span = true;
                        }
                                Page page = Page;
                                string onclick = page != null ? page.ClientScript.GetPostBackEventReference (GetPostBackOptions (), true) : String.Empty;
                                onclick = String.Concat ("setTimeout('", onclick.Replace ("\\", "\\\\").Replace ("'", "\\'"), "', 0)");
-                               w.AddAttribute (HtmlTextWriterAttribute.Onclick, BuildScriptAttribute ("onclick", onclick));
+                               if (common_attrs != null && common_attrs ["onclick"] != null) {
+                                       onclick = ClientScriptManager.EnsureEndsWithSemicolon (common_attrs ["onclick"]) + onclick;
+                                       common_attrs.Remove ("onclick");
+                               }
+                               w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick);
                        }
  
                        if (AccessKey.Length > 0)