It's responsobillity of the code to check if page is valid befor doing any
action....
So your Button_OnClick code should have folowing code as first lines....
if( !this.IsValid)
return;
........
George
> Hi all,
>
[quoted text clipped - 47 lines]
>
> Thanks for any responses.
John Kotuby - 07 Feb 2008 17:40 GMT
George,
Thanks for reminding me of the importance of checking the validity of the
submitted form at the Server, should the user bypass any JavaScript or
otherwise client-side validation. I have implemented your suggestion.
It did solve the problem of the Email being sent with invalid information,
but it required a PostBack and a complete form life-cycle, including another
trip to the database to gather (again) necessary display elements.
See my response to Mark Rae for the final solution, which I hope will help
others who might run across a similar situation.
Thanks again... John
> It's responsobillity of the code to check if page is valid befor doing any
> action....
[quoted text clipped - 58 lines]
>>
>> Thanks for any responses.
> I was under the impression that the Validation Server Controls actually
> perform validation on the Client and don't allow a form to Post if any of
> the validations fail. Please correct me if I am wrong about that.
http://msdn2.microsoft.com/en-us/library/yb52a4x0.aspx
> I will probably have to write my own validators in JavaScript (which I
> thought that ASP.NET 2.0 would help me to avoid).
FWIW, I never ever use the Validation controls...
I have a whole suite of client-side JavaScript validation routines which I
find give me much more control over the entire client-side validation
process...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
John Kotuby - 07 Feb 2008 17:59 GMT
Many thanks Mark,
The link to the explanation of the client-side workings of the Validation
Server controls finally led me to a solution.
I had placed a "filter" on the help searches in MSDN for VS2005 so it only
returned articles for "Web Development".
Apparently, whoever decides what the filters do made it difficult for me to
find the article you pointed me to. From now on I leave the Help
"unfiltered".
Anyway, it was my OnClientClick="return SendMail();" that turned out ot be
the culprit.
It was being called right before the Microsoft generated
DoPostBackWithOptions client-side call, which of course runs the client-side
validation routines. The form was being submitted without client-side
validation, thus underscoring the need for Server-side form validation at
all times.
I moved the call to my function "SendMail();" from the Button OnClientClick
event to the Form onSubmit event so that it gets called only if client-side
validation is successful.
FWIW -- I am now well on my way to completing my own JavaScript validation
library, thanks to a handy tool I downloaded -- RegexBuddy -- to help me
with Regular Expressions. I highly recommend the tool for only about $40.
Thanks again
>> I was under the impression that the Validation Server Controls actually
>> perform validation on the Client and don't allow a form to Post if any of
[quoted text clipped - 10 lines]
> find give me much more control over the entire client-side validation
> process...
Mark Rae [MVP] - 07 Feb 2008 18:01 GMT
> FWIW -- I am now well on my way to completing my own JavaScript validation
> library
Glad to hear it!
Once you have it the way you like it, you'll never use client-side
Validation Controls again...

Signature
Mark Rae
ASP.NET MVP
http://www.markrae.net
> Hi all,
>
[quoted text clipped - 47 lines]
>
> Thanks for any responses.
It sounds like you only want "SendMail()" to run if the page is valid. Try
this link:
http://forums.asp.net/p/1011848/1354154.aspx
John Kotuby - 07 Feb 2008 17:46 GMT
Scott,
Thanks for your suggestion. I implemented it in a slightly different manner.
Instead of what I had origianlly done:
OnClientClick="return SendMail();"
I placed that call in the form onSubmit event instead, so that I could still
gather up the on-screen InnerHtml right before the post. See my response to
Mark Rae for more info on how I solved the problem.
Essentially, though, by making the call to my JavaScript function and
returning "true" I was client-hijacking the Microsoft generated
DoPostbackWithOptions call that followed my Javascript as the 2nd command in
the HTML onClick event...such that the form was submitted without
client-side Validation ever being run.
>> Hi all,
>>
[quoted text clipped - 52 lines]
>
> http://forums.asp.net/p/1011848/1354154.aspx