J
John Kotuby
Hi all,
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. If that is
the case then I will probably have to write my own validators in JavaScript
(which I thought that ASP.NET 2.0 would help me to avoid).
I have a form for filling out Email information which contains validation
controls. In fact I have 2 forms like that with the same validator controls
pointing to the same input fields. They just operate slightly differently
upon post.
One of them seems to work properly and the other one doesn't and I cant seem
to figure out why.
The Form1 that works (validates) properly is posted by the button as below:
<asp:Button runat="server" ID="btnSubmit" Text="Preview"
PostBackUrl="~/Common/EmailList.aspx" ToolTip="Preview Email" />
This Form1 cross posts to another page which shows a preview of the HTML to
be sent in the email and then sends it when the user clicks a "Send" button.
The Form2 that doesn't work (such that it allows the email to be sent
without a subject or email addresses) is posted by the button control below:
<asp:Button runat="server" ID="btnSend" Text="Send" OnClientClick="return
SendMail();" OnClick="SendIt" CausesValidation="true" ></asp:Button>
OnClientClick calls a Javascript function that assembles the Body content
(actually HTML) and places it a hidden field before the form is posted. That
part works fine and the HTML email sends OK. But, the Validation controls
don't seem to work.
Form2 posts back to itself, where it then runs the "SendIt" method that
actually sends the email.
The other difference is the OnClientClick javascript that is called. This is
the form where validation does not operate properly, meaning the
OnClick="SendIt" method is fired even if the form fields do not pass the
validation tests.
Can anyone tell me why the Validation appears to work in one case and not
the other? I have triple checked that all validators are associated with the
correct controls. In fact Form2 was built by copying much of the code from
Form1.
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. If that is
the case then I will probably have to write my own validators in JavaScript
(which I thought that ASP.NET 2.0 would help me to avoid).
I have a form for filling out Email information which contains validation
controls. In fact I have 2 forms like that with the same validator controls
pointing to the same input fields. They just operate slightly differently
upon post.
One of them seems to work properly and the other one doesn't and I cant seem
to figure out why.
The Form1 that works (validates) properly is posted by the button as below:
<asp:Button runat="server" ID="btnSubmit" Text="Preview"
PostBackUrl="~/Common/EmailList.aspx" ToolTip="Preview Email" />
This Form1 cross posts to another page which shows a preview of the HTML to
be sent in the email and then sends it when the user clicks a "Send" button.
The Form2 that doesn't work (such that it allows the email to be sent
without a subject or email addresses) is posted by the button control below:
<asp:Button runat="server" ID="btnSend" Text="Send" OnClientClick="return
SendMail();" OnClick="SendIt" CausesValidation="true" ></asp:Button>
OnClientClick calls a Javascript function that assembles the Body content
(actually HTML) and places it a hidden field before the form is posted. That
part works fine and the HTML email sends OK. But, the Validation controls
don't seem to work.
Form2 posts back to itself, where it then runs the "SendIt" method that
actually sends the email.
The other difference is the OnClientClick javascript that is called. This is
the form where validation does not operate properly, meaning the
OnClick="SendIt" method is fired even if the form fields do not pass the
validation tests.
Can anyone tell me why the Validation appears to work in one case and not
the other? I have triple checked that all validators are associated with the
correct controls. In fact Form2 was built by copying much of the code from
Form1.
Thanks for any responses.