Hi,
I have a user control that has a property named "Text"
Is there any way that I use a RequiredFieldValidator or CompareValidator to
validate my user control's value?
I tried it and I received this error:
Control 'cboCountry' referenced by the ControlToValidate property of
'valCountry' cannot be validated.
Thank you,
MaxOn Jul 13, 10:05 pm, "Max2006" <alanal...@dotnet.itags.org.newsgroup.nospam> wrote:
> Hi,
> I have a user control that has a property named "Text"
> Is there any way that I use a RequiredFieldValidator or CompareValidator t
o
> validate my user control's value?
> I tried it and I received this error:
> Control 'cboCountry' referenced by the ControlToValidate property of
> 'valCountry' cannot be validated.
> Thank you,
> Max
Hi...
i assume you have a control inside the usercontrol that receive input
from user and you do want to validate the input ...
here are the options you have...
1. add the requited field validator for the input in the usercontrol
rather that in the page...
2. validate the text using server side validation... (for this you
need to write a server side validation method...)
Thanks
Md. Masudur Rahman (Munna)
kaz Software Ltd.
www.kaz.com.bd
http://munnacs.110mb.com
Hi Max,
Yes, I agree with Masudur's opinion. Also, if you do want to make Validator
controls directly function against your ascx usercontrol, you can use the
"ValidationPropertyAttribute" class to define a property to be validatable
in your ascx control's code behind.
#ValidationPropertyAttribute Class
http://msdn2.microsoft.com/en-us/li...tionpropertyatt
ribute(VS.80).aspx
Based on my test, through the intellisense not work, you can manually put
usercontrol's ID to validateor's "ControlToValidate" property and so far it
seems only server-side validation is working in this case.
Anyway, I think Masudur's suggested approaches are still the preferred ones
here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Hi Max,
Have you got any further idea on this or does the information helps you
some? Please feel free to post here if there is anything else we can help.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Wednesday, March 28, 2012
The best way to validate UserControls
Labels:
asp,
comparevalidator,
control,
named,
net,
property,
requiredfieldvalidator,
text,
tovalidate,
user,
usercontrols,
validate
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment