Custom Validator - 2 problems

bri189a

Senior Contributor
Joined
Sep 11, 2003
Messages
1,004
Location
VA
I usually stay away from this one because I can get most to work with a regular expression validator.

Anyway, what I have is a ListBox (<select>), and I want to ensure an item is selected prior to the form being submitted. It appears through my testing that the client side script doesn't fire when I submit the form unless I first select an item in the list box (which would take the point out of ensuring an item is selected).

Furthermore, as a back-up I set the Server_OnValidate method to do a similiar check...it never fires, even when I expressly call Page.Validate(), or for that matter event the Validate method of the custom validator.

I haven't ever seen these issues with any of the other validators, since I usually don't mess with this particular validator I figure I must be missing something. Any thoughts would be appreciated.
 
In your "Accept" button event are you doing a check on
If Page.IsValid then
... continue
Else
...
End If

For some reason the custom validators seem to need this. I don't know if there's a way to associate the validator to the SelectedIndexChanged event. I've had to place it in the button I use to determine acceptance of the page.



bri189a said:
I usually stay away from this one because I can get most to work with a regular expression validator.

Anyway, what I have is a ListBox (<select>), and I want to ensure an item is selected prior to the form being submitted. It appears through my testing that the client side script doesn't fire when I submit the form unless I first select an item in the list box (which would take the point out of ensuring an item is selected).

Furthermore, as a back-up I set the Server_OnValidate method to do a similiar check...it never fires, even when I expressly call Page.Validate(), or for that matter event the Validate method of the custom validator.

I haven't ever seen these issues with any of the other validators, since I usually don't mess with this particular validator I figure I must be missing something. Any thoughts would be appreciated.
 
Yes that check is there and even put Page.Validate() before it just to hopefully get it to fire, but it never does. Think I'll do the same thing you did, handle the check in my own script.
 
Back
Top