I see an inaccurate validation behavior on my asp.net (2.0) form. The EnableClientScript property of my validation control is set to True by default, so it performs the validation on clientside. But as soon as this occurs, it also performs the server-side validation, so the page refreshes. When the validation error occurs on clientside, it should not do the validation on serverside (I'm not calling Page.Validate() or doing Page.IsValid). In my past experience, asp.net handled this automatically, but I guess it's not always the case. How can I correct this?
![]() |
0 |
![]() |
Make sure your validator has the Display property set to Dynamic.
Thanks,
Max
Let Me Google That For You!
![]() |
0 |
![]() |
Display
="Dynamic" made no difference. Isn't the Display property for the ErrorMessage or Text property's space allocation? So I think it has nothing to do with the problem I'm having now. Anyway I tried and didn't work. Any other suggestion?
![]() |
0 |
![]() |
My understanding is that the validation controls perform both client-side and server-side validation. This is by design, as it is what you would normally want. Client-side only validation can easily be circumvented by a savvy user - you have to have server-side validation of user input in order to make a web based system secure & robust.
Dave
www.davebartlett.net
![]() |
0 |
![]() |
I think you're missing my point here. I'm with you on the making the app secure, but your input is not really related to my question. So let me repeat/clarify: when the clientside validation is performed, there's no need to make a trip to the server and do the serverside validation. The serverside validation should occur only if javascript is not supported by client. But currently I'm seeing both client and serverside validation happening with one button click (it does the clientside first and then immediately does it again on the serverside). I thought asp.net was smart enough to do the serverside only if javascript was disabled on client. I'm just using a regular RequiredFieldValidator by the way: <asp:RequiredFieldValidator runat="server" id="rfv" ControlToValidate="tb" Display="Dynamic" ErrorMessage="error" />saille:
My understanding is that the validation controls perform both client-side and server-side validation. This is by design, as it is what you would normally want. Client-side only validation can easily be circumvented by a savvy user - you have to have server-side validation of user input in order to make a web based system secure & robust.
![]() |
0 |
![]() |
dude153:
Display
="Dynamic" made no difference. Isn't the Display property for the ErrorMessage or Text property's space allocation? So I think it has nothing to do with the problem I'm having now. Anyway I tried and didn't work. Any other suggestion?Yes, my bad. It should not do that if you have EnableClientScript = true. Can you post your code? Also, try setting this property again in the aspx page.
Thanks,
Max
Let Me Google That For You!
![]() |
0 |
![]() |
Best practice is to always perform validation of user input on the server side. This is the only way to ensure you don't pass bad data, or malicious data further down the stack. Client-side validation is icing on the cake to make your app faster & easier to use. Anyone who can disable javascript can thwart your client side validation.
Dave
www.davebartlett.net
![]() |
0 |
![]() |
By the way, do you have the ValidationGroup set on both the validation control and the button? Maybe thats what you're needing.
Dave
www.davebartlett.net
![]() |
0 |
![]() |
saille:
Best practice is to always perform validation of user input on the server side. This is the only way to ensure you don't pass bad data, or malicious data further down the stack. Client-side validation is icing on the cake to make your app faster & easier to use. Anyone who can disable javascript can thwart your client side validation.
Dave, the problem is not whether to perform client side validation only or both, the problem is that even though client side validation is enabled, it is doing a postback which it shouldn't.
Thanks,
Max
Let Me Google That For You!
![]() |
0 |
![]() |
Found the problem. I had javascript that conflicts with the one generated by asp.net. Thanks.
![]() |
0 |
![]() |
Well there you go...
Thanks,
Max
Let Me Google That For You!
![]() |
0 |
![]() |