[FIX] correctly handle custom onclick attribute when autopostback = true for checkbox
authorEtienne CHAMPETIER <etienne.champetier@fiducial.net>
Fri, 27 Dec 2013 15:30:57 +0000 (16:30 +0100)
committerEtienne CHAMPETIER <etienne.champetier@fiducial.net>
Tue, 1 Apr 2014 09:43:19 +0000 (11:43 +0200)
onclick is in common_attrs not in Attributes, so we can't use BuildScriptAttribute

Signed-off-by: Etienne CHAMPETIER <etienne.champetier@fiducial.net>
mcs/class/System.Web/System.Web.UI.WebControls/CheckBox.cs

index 0169ffa1e7a4687082cb8faff827ecb53c61784a..e57c5969d32775776adb2991644719751080dddc 100644 (file)
@@ -372,7 +372,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)