Răsfoiți Sursa

2005-09-06 Chris Toshok <[email protected]>

	* WebUIValidation.js (ValidatorCommonOnSubmit): reorder things so
	that for validationsummary's we show the message box after we
	display the summary.  This is because the alert blocks further
	execution.
	(ValidatorGetErrorMessage): return the errormessage in preference
	to the text.
	(ValidatorGetText): new function, return the text in preference to
	the error message.
	(ValidatorFailed): use ValidatorGetText, and always set the
	innerHTML, not just when we don't have validationsummary's.


svn path=/trunk/mcs/; revision=49556
Chris Toshok 20 ani în urmă
părinte
comite
dda9d6c2fd

+ 13 - 0
mcs/class/System.Web/resources/ChangeLog

@@ -1,3 +1,16 @@
+2005-09-06  Chris Toshok  <[email protected]>
+
+	* WebUIValidation.js (ValidatorCommonOnSubmit): reorder things so
+	that for validationsummary's we show the message box after we
+	display the summary.  This is because the alert blocks further
+	execution.
+	(ValidatorGetErrorMessage): return the errormessage in preference
+	to the text.
+	(ValidatorGetText): new function, return the text in preference to
+	the error message.
+	(ValidatorFailed): use ValidatorGetText, and always set the
+	innerHTML, not just when we don't have validationsummary's.
+	
 2005-08-27  Chris Toshok  <[email protected]>
 
 	* webform.js: add copyright blurb, and add implementation of

+ 35 - 27
mcs/class/System.Web/resources/WebUIValidation.js

@@ -67,28 +67,6 @@ function ValidatorCommonOnSubmit ()
 			if (header == null)
 				header = "";
 
-			attr = vs.getAttribute ("showmessagebox");
-			if (attr != null && attr.toLowerCase() == "true") {
-				var v_contents = "";
-
-				for (var v in Page_Validators) {
-					var vo = Page_Validators [v];
-
-					if (vo.getAttribute ("isvalid").toLowerCase() == "false") {
-						var text = ValidatorGetErrorMessage (vo);
-						if (text != null && text != "") {
-							v_contents += "-" + text + "\n";
-						}
-					}
-				}
-
-				var alert_header = header;
-				if (alert_header != "")
-					alert_header += "\n";
-				summary_contents = alert_header + v_contents;
-				alert (summary_contents);
-			}
-
 			attr = vs.getAttribute ("showsummary");
 			if (attr == null || attr.toLowerCase() == "true") {
 				var displaymode = vs.getAttribute ("displaymode");
@@ -132,6 +110,28 @@ function ValidatorCommonOnSubmit ()
 				vs.innerHTML = html;
 				vs.style.display = "block";
 			}
+
+			attr = vs.getAttribute ("showmessagebox");
+			if (attr != null && attr.toLowerCase() == "true") {
+				var v_contents = "";
+
+				for (var v in Page_Validators) {
+					var vo = Page_Validators [v];
+
+					if (vo.getAttribute ("isvalid").toLowerCase() == "false") {
+						var text = ValidatorGetErrorMessage (vo);
+						if (text != null && text != "") {
+							v_contents += "-" + text + "\n";
+						}
+					}
+				}
+
+				var alert_header = header;
+				if (alert_header != "")
+					alert_header += "\n";
+				summary_contents = alert_header + v_contents;
+				alert (summary_contents);
+			}
 		}
 	}
 
@@ -357,7 +357,17 @@ function ValidatorUpdateDisplay (v, valid)
 
 function ValidatorGetErrorMessage (v)
 {
-	var text = v.getAttribute ("text");
+	var text = v.getAttribute ("errormessage");
+	if (text == null || text == "")
+		text = v.getAttribute ("text");	
+	if (text == null)
+		text = "";
+	return text;
+}
+
+function ValidatorGetText (v)
+{
+	var text = v.getAttribute ("text");	
 	if (text == null || text == "")
 		text = v.getAttribute ("errormessage");
 	if (text == null)
@@ -367,10 +377,8 @@ function ValidatorGetErrorMessage (v)
 
 function ValidatorFailed (v)
 {
-	var text = ValidatorGetErrorMessage (v);
-	if (text != "" && !have_validation_summaries) {
-		v.innerHTML = text;
-	}
+	var text = ValidatorGetText (v);
+	v.innerHTML = text;
 
 	ValidatorUpdateDisplay (v, false);
 }