Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

The best way to validate UserControls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max2006 - 13 Jul 2007 17:05 GMT
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
Masudur - 14 Jul 2007 13:48 GMT
> Hi,
>
[quoted text clipped - 10 lines]
> 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
Steven Cheng[MSFT] - 16 Jul 2007 06:28 GMT
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/library/system.web.ui.validationpropertyatt
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.
Steven Cheng[MSFT] - 18 Jul 2007 14:34 GMT
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.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.