Home All Groups Group Topic Archive Search About
Author
1 Jul 2005 9:16 AM
Mantorok
Hi all

ASP.Net 2.0 question.

Is it possible to have a textbox always display a particular format, my
client wishes to have the textbox always display the text in this format -
£0,000.00.

Is there anyway of achieving this?

Thanks
Kev

Author
1 Jul 2005 3:00 PM
Peter Blum
You can assign that text to the Text property on the server side. Use the
String.Format() method to convert your decimal value into the currency
format.

However, the TextBox does not offer the javascript necessary to preserve the
format as the user edits. You should always use a validator to confirm an
entry is correct (always assume that any client-side code you have will be
disabled). Normally the CompareValidator with Operator=DataTypeCheck and
Type=Currency would assist you here. But it doesn't accept the currency
symbol character. To solve this, I recommend putting the currency symbol
outside the TextBox in a Label control. (It makes data entry easier for the
user too.)

Third parties have written textboxes with support for currency entry. I am
an author of one of them in my Professional Validation And More Suite or its
VAM: Data Entry Controls module. I supply integer, decimal and currency
entry. My CurrencyTextBox has a property to permit the currency symbol and
thousands separator symbol. To handle the most browsers and the
idiosyncrasies of users, it filters illegal characters and uses fuzzy logic
to overcome unusual entries. Then it reformats as the user tabs off. That
way, the user can enter "1000" or "1,000" or "£1000.00" etc.

Professional Validation And More (http://www.peterblum.com/vam/home.aspx)
includes a much more powerful set of validators. For example, its
DataTypeCheckValidator (used to confirm the pattern of text) supports the
currency symbol and thousands separators. It is compatible with ASP.NET 2.0.

--- Peter Blum
www.PeterBlum.com
Email: PLB***@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

Show quoteHide quote
"Mantorok" <n***@tiscali.co.uk> wrote in message
news:da31k2$okl$1@newsfeed.th.ifl.net...
> Hi all
>
> ASP.Net 2.0 question.
>
> Is it possible to have a textbox always display a particular format, my
> client wishes to have the textbox always display the text in this format -
> £0,000.00.
>
> Is there anyway of achieving this?
>
> Thanks
> Kev
>