2

I've been reading about ASP.NET Validation and found a related question on SO's How do I get Client-side validation of ASP.Net page to run?, but nothing seems to address why some of this validation would be posting to the Browser.

Obviously, something is wrong. The following text is being displayed:

var Page_ValidationActive = false; if (typeof(ValidatorOnLoad) == "function") { ValidatorOnLoad(); } function ValidatorOnSubmit() { if (Page_ValidationActive) { return ValidatorCommonOnSubmit(); } else { return true; } } //]]>

That last little bit looks like a CDATA closing tag, and the only CDATA tags I have are ones linked in from social media sites like Google or Facebook.

Could anyone tell me what causes this?

It is possible I have another setting telling the client to dump output to the browser like I did in this post.

Community
  • 1
  • 1

2 Answers2

1

The code there has has a CDATA section in it. Your code would too if you copied it.

I experimented and got the same result by moving the CDATA section above the script, like this:

<![CDATA[
<script type="text/javascript">
var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
//]]>
</script>

In that case, the CDATA tag should be moved to below the script tag. Or, just remove the CDATA tags altogether.

uınbɐɥs
  • 7,236
  • 5
  • 26
  • 42
  • Isn't this code part of Microsoft's ASP? Meaning, I have no access to this code, and it does not appear anywhere in what I wrote. –  Aug 03 '12 at 13:26
  • I don't know if it is part of ASP or not (you would know more about ASP than I do), but does setting XHTML conformance help, like in [this comment](http://stackoverflow.com/q/944525/1421049#comment-1480400)? – uınbɐɥs Aug 03 '12 at 19:23
1

I do not understand why the script was displayed on the web page, but the error was caused because one of my validation controls had mistakenly been excluded from the group.

Once I included all of my validation controls in the validation group, the error went away.

If someone knows why the error was being echoed to the browser, please let me know so that I can disable this "feature" from my website.