Is it possible to have a RequiredFieldValidator monitor more
than one control? I want to validate a textbox and a calendar
control with one validator. Or is there another way to do this
other than having a single validator for each control?
Thanks.
Printable View
Is it possible to have a RequiredFieldValidator monitor more
than one control? I want to validate a textbox and a calendar
control with one validator. Or is there another way to do this
other than having a single validator for each control?
Thanks.
Robb I think you'd have to change it via code dynamically.Quote:
Originally posted by RobDog888
Is it possible to have a RequiredFieldValidator monitor more
than one control? I want to validate a textbox and a calendar
control with one validator. Or is there another way to do this
other than having a single validator for each control?
Thanks.
Me.RequiredFieldValidator.ControlToValidate
Yes, Jon I saw that possibility. But if it gets changed through
code then the validator will stop monitoring the previous control
and change to only the new one. So if I have 5 textboxes I want
to validate upon a single button press then I would have to write
more code than if I just created a validator for each. Guess I will
just have to settle for one validator per control. Just more to
manage thats all. :( Unless you can think of another way?
Thanks Jon. :)
No you dont have to do it like this at all. All you need is a validation summary. I use validation summaries on like register pages where I need to validate more than one control.Quote:
Originally posted by RobDog888
Yes, Jon I saw that possibility. But if it gets changed through
code then the validator will stop monitoring the previous control
and change to only the new one. So if I have 5 textboxes I want
to validate upon a single button press then I would have to write
more code than if I just created a validator for each. Guess I will
just have to settle for one validator per control. Just more to
manage thats all. :( Unless you can think of another way?
Thanks Jon. :)
A validation summary takes all the controls into one single message or label and displays the message yyou want.
Look it up or I can post an example.
Jon
Ok, I will look it up and if I still have problems I'll be back.
Thanks for your help Jon!
One validator per control....unless you inherit from the basevalidator class (don't know the exact name right now) and add the custom code to it.
The problem is that you won't be able to flag which control caused the problem to the user.
Better stick with one validator per control.
Ok, I found it and tried it out on two requiredfieldvalidators
and it appears to be a summary of all the rfvs per page. Is it just
to summarize rfvs or ???
Thanks.
Morning Rob,Quote:
Originally posted by RobDog888
Ok, I found it and tried it out on two requiredfieldvalidators
and it appears to be a summary of all the rfvs per page. Is it just
to summarize rfvs or ???
Thanks.
Yes :(.
I think you will need a rfv for each field, and you can summarize using the validation summary.
I got it working fine now for my page, but I have a Calendar control
on it and it needs to be validated too. There is no Calendar items
in the dropdown list for controls to validate and if I assign it in
code it gives a error. How can I, other than code for a #12:00:00
AM# date, validate the calendar?
Thanks again.
Hi Rob,Quote:
Originally posted by RobDog888
I got it working fine now for my page, but I have a Calendar control
on it and it needs to be validated too. There is no Calendar items
in the dropdown list for controls to validate and if I assign it in
code it gives a error. How can I, other than code for a #12:00:00
AM# date, validate the calendar?
Thanks again.
Click on this control look for "Causes Validation" as a property.
Set it to yes..if you see it!
Ok, I will look for it when I get home.
Thanks.
Jon, I looked and I know I'm not blind but I dont see it. I am using
the standard Calendar control from the toolbox.
:confused:
I dont think it has one, you will have to code it...Quote:
Originally posted by RobDog888
Jon, I looked and I know I'm not blind but I dont see it. I am using
the standard Calendar control from the toolbox.
:confused:
check if its null or what not, btw usually what I do is use a text box with a button next to it. If you click the button a calendar opens. That way you can place a required field validatar against the text box.
Jon
For anyone else:
Microsoft has a nice page dealing with validation in general.
Great stuff:
http://msdn.microsoft.com/library/de...erControls.asp
Thanks, Jon. That link will help me to understand the other types
of validation.