PC Review


Reply
Thread Tools Rate Thread

The best way to validate UserControls

 
 
Max2006
Guest
Posts: n/a
 
      13th Jul 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
 
      14th Jul 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
 
      16th Jul 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
 
      18th Jul 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
Rate This Thread
Rate This Thread:

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 Microsoft ASP .NET 0 5th Sep 2008 02:29 PM
Cannot validate keep getting validate your account message =?Utf-8?B?UmljaGFyZA==?= Microsoft Outlook Discussion 1 9th Sep 2007 07:58 AM
What's the best way to reload data into multiple usercontrols on postback? Gummy Microsoft ASP .NET 0 19th Sep 2006 03:36 AM
Adding usercontrols to other usercontrols =?Utf-8?B?RW1tYQ==?= Microsoft C# .NET 2 27th Oct 2004 03:07 PM
UserControls in UserControls? Phill. W Microsoft VB .NET 0 10th May 2004 03:11 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:01 PM.