can I use this same Validation control to validate multiple textboxes?

  • Thread starter Thread starter Bibin
  • Start date Start date
B

Bibin

Dear All,

I am developing a POS application in ASP.Net. In my ASP.Net forms,
I may be having around 15 TextBox controls. I will need to validate these
controls
while editing.

I just want to know that, can we able to use a single validation control for
multiple
TestBox? Becaue some textboxes will be having validation of similar types.
So if
I am puting a "CustomValidationControl", can I use this same control to
validate
multiple textboxes?

What my intention is to avoid putting validation control for each and every
TextBoxes
to be validated.

If anybody tried this and got a solution, please do reply.

Thanks and Regads,

Bibin.
 
Bibin said:
Dear All,

I am developing a POS application in ASP.Net. In my ASP.Net forms,
I may be having around 15 TextBox controls. I will need to validate these
controls
while editing.

I just want to know that, can we able to use a single validation control for
multiple
TestBox? Becaue some textboxes will be having validation of similar types.
So if
I am puting a "CustomValidationControl", can I use this same control to
validate
multiple textboxes?

What my intention is to avoid putting validation control for each and every
TextBoxes
to be validated.

If anybody tried this and got a solution, please do reply.

Sorry, you need one per control to be validated. There is only the one
ControlToValidate property on each validation control.
 
Dear John,

Thanks for your reply. But there is a property called "ControlToValidate"
for these
validation controls. It can be setted in the runtime also. So can you please
tell me
how can we use this property in the runtime to validate multiple controls.

Thanks & Regards,

Bibin.
 
Bibin said:
Dear John,

Thanks for your reply. But there is a property called "ControlToValidate"
for these
validation controls. It can be setted in the runtime also. So can you please
tell me
how can we use this property in the runtime to validate multiple controls.

ControlToValidate cannot be used that way. It indicates the one-and-only
control to be validated by this particular validation control.

Note that the validation controls all derive from the Label control. A
validation control is thus a smart label - one which will only be visible if
the validation has failed. As a result, you need one of these "labels" next
to each control to be validated.

Now, if you're trying to avoid dragging large numbers of validation
controls, you can try creating them at runtime. You can either create one
validation control per TextBox, or you could even create your own
ValidatedTextBox control which would have both the TextBox and the
corresponding validation controls in it. You would then be able to drag
ValidatedTextBox controls onto your form. You could even get fancier and add
a label in front of the TextBox, all in one control.

You might want to take a look at the following: Developing a Composite
Control
(http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/ht
ml/cpcondevelopingcompositecontrols.asp). Composite controls can be very
easy to develop, since most of the work is done in the controls out of which
the composite is formed.
 
Back
Top