Format/Mask text input

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to force a format to a bound data text box. For things like phone
number, zipcode, etc. (xxx) xxx-xxxx where the X's are what the user types
and the ( ) and - are fixed chars to make sure the user puts the phone number
in the same format every time.

I'm sure this is easy (is in the other languages...), but in my switching
over to .NET, I am still trying to figure out many things.

Please point me in the right direction....
 
You mean there is no native way in VB .NET to put a mask/format on a field so
that the field is formatted for the user??? This would seem like a HUGE
oversight.

There's gotta be something I am overlooking.
 
No offense, but I agree with Stress Puppy...why should a million
programmes have to write 1/2 page of code for what is an obvious
feature that any input control should have?

John
 
J L said:
Hi Stress,
Check out this link...seems to be a perfect solution with lots of
added features I had not even considered:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadvnet/html/vbnet04082003.asp

John


Thanks!!!! I'll take a look at this.

As for the "oversight" part, I have spent the last several years in Delphi
(been a consultant and programmer for 17+ years) and it is a standard thing.
It is a published property and you use standard format characters to set it
up the way you want at design time. Then at run time, it handles it all for
you. It is has an option so you can store the extra characters with the data
in the DB or not. Very simple and great foresight.

Not "picking" on .NET, but I have run into a few things that I would have
thought would have been no brainers to make the developers life easier. Hey,
but since MS doesn't ask my opinion.......

Since it is 1/2 page of code, I guess I could just inherit and create my own
control and then just reuse the control through all my apps. I think I'll
take a look at the stuff John mentions first.

Sahil - thanks for the link and the input.
John - thanks for the link (and for agreeing with me) :-)
 
Because, it is not an obvious solution.
Your required mask would be different than someone else's.
Plus it'd kill Infragistics and it's brothers.

Either way, personally I don't care as much - but it's not a (ALL CAPS HUGE)
oversight. Maybe a minor oversight at best, if that.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/
 
Sahil said:
Because, it is not an obvious solution.
Your required mask would be different than someone else's.
Plus it'd kill Infragistics and it's brothers.

Either way, personally I don't care as much - but it's not a (ALL CAPS HUGE)
oversight. Maybe a minor oversight at best, if that.

- Sahil Malik
http://codebetter.com/blogs/sahil.malik/

Phone number, social security number, currency, integer, date, time,
etc. all seem like pretty obvious masks.

It would seem to make more sense that they threw a bone to Infragistics
than just overlooked the need for such fundamental text input validation
controls.
 
Back
Top