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...

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

index 905740a1ea9d9f4d4e896cadb7e7ceaa1e177f25..27c3a7fb9dc870f7018c9a6956ef0871173ecb54 100644 (file)
@@ -370,7 +370,11 @@ namespace System.Web.UI.WebControls
                                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)