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 / Windows Forms / WinForm General / October 2004

Tip: Looking for answers? Try searching our database.

Easy way to datatype validate TextBoxes

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Frank M - 14 Oct 2004 17:19 GMT
In a form I have a number of textboxes that is to receive different types of
data from the user. I can of course validate what has been typed in when the
user press the Ok button by parsing through the contents of the individual
textboxes. However, the .NET framework being so extensive, I was wondering if
there were not already some smart way of handling this validation rather than
having to program it by yourself.

A datatype property that could be set on the textbox or perhaps an object
that could parse and validate it according to datatype would come in handy.
E.g. if you had a date TextBox, it could check that a valid date had been
entered, or perhaps even preventing the user from enterering invalid data in
the first place.
For numbers it could be an enforced format with only so many digits allowed
and thousand dividers and decimal points automatically displayed as well as
any currency characters. I guess I am looking for something like the format
that can be assigned to cells in Excel.

There is a mention of format strings, but the purpose of these seems more to
be a handling or display of a string which is already given, rather than
validating an entry of data or even preventing something wrong from being
entered in the first place.

I hope anyone has some usuful suggestions. If not I can make some methods
myself that I can put in a class for reuse. But with this huge framework, one
would think that something so general was already included.

Best regards,

Frank M.
Sijin Joseph - 15 Oct 2004 05:07 GMT
You are right there is a better way, they are called Validator control
and implement IExtenderProvider so that you can specify the type of
validation that you need on your controls in design view, just ike you
specify the tooltips for toolTipProvider.

Here are some great articles and implementations of the same
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/wi
nforms03162004.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/wi
nforms04202004.asp

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnforms/html/wi
nforms05182004.asp


This has some good validator implementations as well as other cool stuff.
http://www.genghisgroup.com/

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

> In a form I have a number of textboxes that is to receive different types of
> data from the user. I can of course validate what has been typed in when the
[quoted text clipped - 25 lines]
>
> Frank M.
Frank M - 15 Oct 2004 16:09 GMT
Thanks a lot! That is just what I was looking for.

Best regards,

Frank M.

> You are right there is a better way, they are called Validator control
> and implement IExtenderProvider so that you can specify the type of
[quoted text clipped - 42 lines]
> >
> > Frank M.

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.