diff options
author | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2005-11-21 21:41:45 +0300 |
---|---|---|
committer | Gonzalo Paniagua Javier <gonzalo.mono@gmail.com> | 2005-11-21 21:41:45 +0300 |
commit | b503884e37bd73594838b79e7ac22aa5fd6713ff (patch) | |
tree | 54e69fa844bbdbcc3abbcc509369de2d86c05826 /mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs | |
parent | 920315e488b89abbc071ad2001f7a822d06bea04 (diff) |
2005-11-21 Gonzalo Paniagua Javier <gonzalo@ximian.com>
* HtmlInputButton.cs: render the onclick attribute only when the
button is a 'submit' and no validators or when the button is a
'button' and there's a registered ServerClick event. Fixes bug #76781.
svn path=/trunk/mcs/; revision=53316
Diffstat (limited to 'mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs')
-rw-r--r-- | mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs index dd4a7bab981..d31ca9a5e6a 100644 --- a/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs +++ b/mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs @@ -27,6 +27,7 @@ // using System.ComponentModel; +using System.Globalization; using System.Security.Permissions; namespace System.Web.UI.HtmlControls { @@ -140,9 +141,27 @@ namespace System.Web.UI.HtmlControls { server_click (this, e); } + bool RenderOnClick () + { + if (Page == null || !CausesValidation) + return false; + + CultureInfo inv = CultureInfo.InvariantCulture; + string input_type = Type; + if (0 == String.Compare (input_type, "submit", true, inv) && + Page.Validators.Count > 0) + return true; + + if (0 == String.Compare (input_type, "button", true, inv) && + Events [ServerClickEvent] != null) + return true; + + return false; + } + protected override void RenderAttributes (HtmlTextWriter writer) { - if (CausesValidation && Page != null) { + if (RenderOnClick ()) { string oc = null; ClientScriptManager csm = new ClientScriptManager (Page); if (Page.AreValidatorsUplevel ()) { |