custom validators with redirection

egdotnet

Regular
Joined
May 16, 2004
Messages
50
i'm trying to create a registration form on my asp.net page with a required field validator on one text box and some custom validators for a textbox, a calendar, & a drop down list. the custom validators work fine with the submit button, but when i add a "response.redirect" string at the bottom of the submit sub, only the required field validator works.

does anybody know why & how to fix it?

thanks,
Eric
 
It's easy as hell (you'll soon realize).
Being redirected... code execution is stoped. So... the validating is done ONLY AFTER the current procedure (when your code as completed execution). However... it's like you've made a break or something like this. Response.Redirect will cut your code right where he is.

You'll have to move this code elsewhere or... look at the 2nd parameters... it ask you if you want to end interpretation or not... might work. But I would rater change your redirection to somewhere else.
 
then what's the best way to do a regular registration form w/ validators, because it doesn't really help much if it can't take you to a new page so the user actually knows he registered successfully?
 
what i did was to create a boolean variable that becomes false if args.isvalid = false and true if args.isvalid = true. then for the submit button, i said that if all the variables are true, do..., otherwise it just validates. how does that sound?
 
Hi,
I've encountered the same problem.
what I did in the end (and it works) was to use the old fashion VB validation.
I just deleted all the validation components of .net and used the way that I used with ASP:

Code:
<HEAD>
<script language="vbscript">
function Form1_onSubmit()
	Form1_OnSubmit = False
	if document.Form1.username.value = "" then
		document.getElementById("UserNameErr").innerHTML = "Please enter user name"
		exit function
	end if
	Form1_OnSubmit = true
end function
</script>
</HEAD>
 
Back
Top