J
jm
I have this CustomValidator:
<asp:CustomValidator runat="server"
OnServerValidate="ValidateThis"
Display="Dynamic"
ControlToValidate="txtMyTextBox"
ErrorMessage="Not a valid entry"/>
On my server side scripts, I have:
sub ValidateThis(obj as Object, args as _
ServerValidateEventArgs)
if len(args.Value) < 8 then
exit sub <---will this stop the submit from firing?
else
submit() <---what argument
end if
end sub
Sub submit(Source As Object, e As EventArgs)
.... put stuff in a database too long to list
end sub
Okay, what I am trying to do is validate args.value (a textbox) and if
it meets or does not meet the criterion, then either stop everything
or submit to the database.
The problem is that no matter what I put in the ValidateThis sub, the
submit will always work. How do I use the OnServerValidate to stop
the entire page from submitting what's on the form. Also, if it does
pass my criterion, how do I get it too submit. Submit has the two
arguments, but I don't know what they want (got it from somewhere); it
does work. The form works, the database inserts data like I want. I
just need to know how to stop it from submitting based on invalid data
- and I don't want to use JavaScript. I can do that already. I want
to do it in .NET. Thanks for any help.
<asp:CustomValidator runat="server"
OnServerValidate="ValidateThis"
Display="Dynamic"
ControlToValidate="txtMyTextBox"
ErrorMessage="Not a valid entry"/>
On my server side scripts, I have:
sub ValidateThis(obj as Object, args as _
ServerValidateEventArgs)
if len(args.Value) < 8 then
exit sub <---will this stop the submit from firing?
else
submit() <---what argument
end if
end sub
Sub submit(Source As Object, e As EventArgs)
.... put stuff in a database too long to list
end sub
Okay, what I am trying to do is validate args.value (a textbox) and if
it meets or does not meet the criterion, then either stop everything
or submit to the database.
The problem is that no matter what I put in the ValidateThis sub, the
submit will always work. How do I use the OnServerValidate to stop
the entire page from submitting what's on the form. Also, if it does
pass my criterion, how do I get it too submit. Submit has the two
arguments, but I don't know what they want (got it from somewhere); it
does work. The form works, the database inserts data like I want. I
just need to know how to stop it from submitting based on invalid data
- and I don't want to use JavaScript. I can do that already. I want
to do it in .NET. Thanks for any help.