Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > The best way to validate UserControls

Reply
Thread Tools

The best way to validate UserControls

 
 
Max2006
Guest
Posts: n/a
 
      07-13-2007
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,
Max


 
Reply With Quote
 
 
 
 
Masudur
Guest
Posts: n/a
 
      07-14-2007
On Jul 13, 10:05 pm, "Max2006" <(E-Mail Removed)> wrote:
> 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,
> 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

 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-16-2007
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/lib...ionpropertyatt
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.



 
Reply With Quote
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      07-18-2007
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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Validators to validate UserControls Nathan Sokalski ASP .Net Web Controls 0 09-05-2008 01:29 PM
Using Validators to validate UserControls Nathan Sokalski ASP .Net 0 09-05-2008 01:29 PM
What's the best way to reload data into multiple usercontrols on postback? Gummy ASP .Net 0 09-19-2006 02:36 AM
Best event to load usercontrols in ASP.NET 2.0 Nay ASP .Net Building Controls 0 02-25-2006 10:45 AM
Any way to avoid mass conversion of #INCLUDE files to UserControls? JJA ASP .Net Building Controls 13 07-27-2004 08:07 PM



Advertisments