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

Shouldn't server validation always occur when CausesValidation is true??

P: n/a
I recently had a problem where my required field validator stopped working.
But, the page still posted back and tried to insert a record into the
database without performing server-side validation. I discovered that there
was no aspnet_client folder in the root of my IIS Web site, and when I ran
"aspnet_regiis -c", client-side validation was working again. However, what
I don't understand is why the required field validator did not validate on
the server.

I have a Button WebControl with CausesValidation = True and a
RequiredFieldValidator with EnableClientScript = True. I thought that
client-side validation provided a nice user experience and reduced
postbacks, but that server-side validation was ALWAYS performed.

Can someone explain why not having the aspnet_client folder would then cause
server-side validation to stop working???

Also, on my Windows 2000 Server SP4, the following javascript code is
emitted in the page in question (even after restoring aspnet_client):

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if ((typeof(Page_ValidationVer) != "undefined") && (Page_ValidationVer
== "125"))
ValidatorOnLoad();
}
-----------------------------------

But on my windows XP Pro SP2 development machine, the following code is
emitted in this page:

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if (typeof(Page_ValidationVer) == "undefined")
alert("Unable to find script library
'/aspnet_client/system_web/1_1_4322/WebUIValidation.js'. Try placing this
file manually, or reinstall by running 'aspnet_regiis -c'.");
else if (Page_ValidationVer != "125")
alert("This page uses an incorrect version of WebUIValidation.js.
The page expects version 125. The script library is " + Page_ValidationVer +
".");
else
ValidatorOnLoad();
}
-----------------------------------

If the Win2k server had emitted the checks and alert() lines, I would have
been able to find the cause of the problem much quicker. Does anyone know
what accounts for the difference and what I can do to get my server to emit
the second code fragment???
Feb 28 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
for serverside validation to run, your backend code must call it, say thru
accessing the IsValid property which in turn will fire the validation
routines.

-- bruce (sqlwork.com)

"dustbort" <dustbort at yahoo dot com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I recently had a problem where my required field validator stopped working.
But, the page still posted back and tried to insert a record into the
database without performing server-side validation. I discovered that
there was no aspnet_client folder in the root of my IIS Web site, and when
I ran "aspnet_regiis -c", client-side validation was working again.
However, what I don't understand is why the required field validator did
not validate on the server.

I have a Button WebControl with CausesValidation = True and a
RequiredFieldValidator with EnableClientScript = True. I thought that
client-side validation provided a nice user experience and reduced
postbacks, but that server-side validation was ALWAYS performed.

Can someone explain why not having the aspnet_client folder would then
cause server-side validation to stop working???

Also, on my Windows 2000 Server SP4, the following javascript code is
emitted in the page in question (even after restoring aspnet_client):

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if ((typeof(Page_ValidationVer) != "undefined") && (Page_ValidationVer
== "125"))
ValidatorOnLoad();
}
-----------------------------------

But on my windows XP Pro SP2 development machine, the following code is
emitted in this page:

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if (typeof(Page_ValidationVer) == "undefined")
alert("Unable to find script library
'/aspnet_client/system_web/1_1_4322/WebUIValidation.js'. Try placing this
file manually, or reinstall by running 'aspnet_regiis -c'.");
else if (Page_ValidationVer != "125")
alert("This page uses an incorrect version of WebUIValidation.js.
The page expects version 125. The script library is " + Page_ValidationVer
+ ".");
else
ValidatorOnLoad();
}
-----------------------------------

If the Win2k server had emitted the checks and alert() lines, I would have
been able to find the cause of the problem much quicker. Does anyone know
what accounts for the difference and what I can do to get my server to
emit the second code fragment???

Feb 28 '06 #2

P: n/a
No, I don't think so. From the .NET Framework Class Library under
Button.CausesValidation Property:

"By default [CausesValidation = True], page validation is performed when a
Button control is clicked. Page validation determines whether the input
controls associated with a validation control on the page all pass the
validation rules specified by the validation control."

This means that page validation is automatically performed when when
CausesValidation = True.
My understanding is that you only have to explicitly call Validate() and
check IsValid if you have set CausesValidation = False because you want to
do selective validation. In my case, CausesValidation = True . So why
didn't the page validate on the server?

"Bruce Barker" <br******************@safeco.com> wrote in message
news:ek**************@TK2MSFTNGP11.phx.gbl...
for serverside validation to run, your backend code must call it, say thru
accessing the IsValid property which in turn will fire the validation
routines.

-- bruce (sqlwork.com)

"dustbort" <dustbort at yahoo dot com> wrote in message
news:%2***************@TK2MSFTNGP12.phx.gbl...
I recently had a problem where my required field validator stopped
working. But, the page still posted back and tried to insert a record into
the database without performing server-side validation. I discovered that
there was no aspnet_client folder in the root of my IIS Web site, and when
I ran "aspnet_regiis -c", client-side validation was working again.
However, what I don't understand is why the required field validator did
not validate on the server.

I have a Button WebControl with CausesValidation = True and a
RequiredFieldValidator with EnableClientScript = True. I thought that
client-side validation provided a nice user experience and reduced
postbacks, but that server-side validation was ALWAYS performed.

Can someone explain why not having the aspnet_client folder would then
cause server-side validation to stop working???

Also, on my Windows 2000 Server SP4, the following javascript code is
emitted in the page in question (even after restoring aspnet_client):

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if ((typeof(Page_ValidationVer) != "undefined") && (Page_ValidationVer
== "125"))
ValidatorOnLoad();
}
-----------------------------------

But on my windows XP Pro SP2 development machine, the following code is
emitted in this page:

-----------------------------------
if (typeof(clientInformation) != "undefined" &&
clientInformation.appName.indexOf("Explorer") != -1) {
if (typeof(Page_ValidationVer) == "undefined")
alert("Unable to find script library
'/aspnet_client/system_web/1_1_4322/WebUIValidation.js'. Try placing this
file manually, or reinstall by running 'aspnet_regiis -c'.");
else if (Page_ValidationVer != "125")
alert("This page uses an incorrect version of WebUIValidation.js.
The page expects version 125. The script library is " +
Page_ValidationVer + ".");
else
ValidatorOnLoad();
}
-----------------------------------

If the Win2k server had emitted the checks and alert() lines, I would
have been able to find the cause of the problem much quicker. Does
anyone know what accounts for the difference and what I can do to get my
server to emit the second code fragment???


Feb 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.