瀏覽代碼

The problem was in HtmlInputButton.RenderAttributes().
Before adding the script to the HTML, the number of Validators should
be checked.

svn path=/trunk/mcs/; revision=21119

Alon Gazit 22 年之前
父節點
當前提交
da27ee2dbb

+ 5 - 0
mcs/class/System.Web/System.Web.UI.HtmlControls/ChangeLog

@@ -1,3 +1,8 @@
+2003-12-14  Alon Gazit <[email protected]>
+	* HtmlInputButton.cs: The problem was in RenderAttributes().
+	Before adding the script to the HTML, the number of Validators should 
+	be checked. fixes bug #52158.
+
 2003-12-07  Alon Gazit <[email protected]>
 	* HtmlTableCell.cs: fixing a typo in NoWrap property. 
 

+ 13 - 10
mcs/class/System.Web/System.Web.UI.HtmlControls/HtmlInputButton.cs

@@ -33,20 +33,23 @@ namespace System.Web.UI.HtmlControls{
 		{
 			if (Page != null && CausesValidation) {
 				string type = Type;
+				Console.WriteLine(type);
 				if (String.Compare (type, "button", true) == 0 || String.Compare (type, "submit", true) == 0) {
 					string script = Page.GetPostBackClientEvent (this, String.Empty);
-					AttributeCollection coll = Attributes;
-					if (coll ["language"] != null)
-						coll.Remove ("language");
-					writer.WriteAttribute ("language", "javascript");
+					if (script != null && Page.Validators.Count > 0){
+						AttributeCollection coll = Attributes;
+						if (coll ["language"] != null)
+							coll.Remove ("language");
+						writer.WriteAttribute ("language", "javascript");
 
-					string onclick;
-					if ((onclick = coll ["onclick"]) != null) {
-						script = onclick + " " + script;
-						coll.Remove ("onclick");
+						string onclick;
+						if ((onclick = coll ["onclick"]) != null) {
+							script = onclick + " " + script;
+							coll.Remove ("onclick");
+						}
+						
+						writer.WriteAttribute ("onclick", script);
 					}
-
-					writer.WriteAttribute ("onclick", script);
 				}
 			}