By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,969 Members | 1,564 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,969 IT Pros & Developers. It's quick & easy.

Is the javascript WebUiValidation.js no longer available for viewing in 2.0?

P: n/a
It looks like this is now an embedded resource. So is it permanently

In earlier versions of .Net, I made a simple change to the
WebUiValidation.js so that the validation summary was refreshed
whenever a validator fired on the client side. That way, if my
validator text was simply "*", I didn't have to hit the submit button
to see the actual message "Last Name is required" in the summary. It
was a slick little improvement, but it looks like I can't incorporate
this modification into my 2.0 project. Or is there?

Is it me, or does it not seem that my modification should be the
default behavior for the summary control anyway?


Jun 7 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
OK, I navigated to the axd file, and saved it to my machine. I can now
at least see the functions being run. I'm hoping to be able to hijack
a function so I can use my custom script to automatically update the
summary control. I'll keep you guys posted in case you're interested
in doing the same thing.

Jun 7 '07 #2

P: n/a
Well, I figured out a nice way to do this in 2.0. It may seem like a
hack, but it seems fairly clean to me. I only tested this on IE7 and
Firefox 2.0 and on a simple page with two validation groups, but it
seems to work nicely.

Basically, you need to hijack two javascript functions in the UI
validation resource...ValidatorUpdateIsValid() and
ValidationSummaryOnSubmit(). To view the original, just navigate to
the second <scriptAXD file in your resulting page source (view
source and paste into address bar). You'll have to save the AXD file,
and then open it in notepad to see the actual javascript.

Copy the two functions you want to hijack (ValidatorUpdateIsValid()
and ValidationSummaryOnSubmit()) into a new js file and then use
ClientScript.RegisterStartupScript to register a <script
src='hijack.js' type='text/javascript'></scripttag in the document.
This must appear after the script tag that registers the UIValidation
resource which is why I used RegisterStartUpScript and not
RegisterClientScriptBlock. You need to do this on every page you want
this behavior. I'd suggest creating either a base page class or
utility class function.

The changes you make to these functions are pretty simple:

function ValidatorUpdateIsValid() {
Page_IsValid = AllValidatorsValid(Page_Validators);
refreshSummaries(); // <--- I ADDED THIS LINE

function ValidationSummaryOnSubmit(validationGroup) {


// = "none"; <-- I COMMENTED OUT THIS


s += first;
for (i=0; i<Page_Validators.length; i++) {
if (!Page_Validators[i].isvalid &&
typeof(Page_Validators[i].errormessage) == "string" &&
Page_Validators[i].validationGroup == validationGroup) {
s += pre + Page_Validators[i].errormessage +



I didn't like having to hijack the previous function because of its
size, but it was the only way to get the behavior I wanted.

Then add two new functions:

function refreshSummaries() {
if (typeof(Page_ValidationSummaries) == "undefined") {
for (var i=0;i<Page_ValidationSummaries.length;i++) {
if (isGroupValid(Page_ValidationSummaries[i])) {
// hide
Page_ValidationSummaries[i].style.display = "none";
} else {
// Refresh


function isGroupValid(summary) {

if (typeof(Page_Validators) == "undefined") {
return true;

var summaryGroupName;
var validatorGroupName;

if ((typeof(summary.validationGroup) == "undefined") ||
(summary.validationGroup == null)) {
summaryGroupName = '';
} else {
summaryGroupName = summary.validationGroup;

for (var i=0;i<Page_Validators.length;i++) {

if ((typeof(Page_Validators[i].validationGroup) ==
"undefined") || (Page_Validators[i].validationGroup == null)) {
validatorGroupName = '';
} else {
validatorGroupName = Page_Validators[i].validationGroup;

if (validatorGroupName == summaryGroupName) {
if (!Page_Validators[i].isvalid) {
return false;

return true;

What my new validation code does is update the summaries at the same
time the individual validators are fired. That way, when you leave a
required field, you can see the "*" text from the validation control
as well as the real error message "Field A is required" in the
summary. It also changes the default behavior where only one summary
is shown at a time. If you have multiple summaries, they stay visible
if you have failed validations. The default behavior, however, is
still exhibited when you try to submit a form (only the val summary of
the applicable group is displayed).
If you have any questions or want to share ideas or report bugs,
contact me at jjbutera-AT-HOTMAIL-DOT-COM.

This code is provided AS-IS and I offer no warranties. There may be
some improvements and further testing needed, but try it out and let
me know what you think!

Jun 7 '07 #3

P: n/a
I've fixed some bugs that arise when using validators with
validationgroups along with others without a validationgroup. My
previous post should at least help you out. E-mail me for the updated
js file if you're interested.

Jun 7 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.