0

I have been developing an application in asp.net mvc3. We have used models to display view and save model values to database. I came up with a requirement where in the user interface if user enters 50000 we need to format the value and display it in format 50, 000.

It is not possible for textbox that displays integer values to have value of 50,000. We have used model validation to do this thing. So it won't allow me to have 50,000 in the textbox. Unobtrusive javascript would instantly show error message and make the textbox red.

How can i achieve this functionality, please guide me.

marcind
  • 52,944
  • 13
  • 125
  • 111
NCCSBIM071
  • 1,207
  • 1
  • 16
  • 30
  • 1
    Check out this post, it may help you out: http://stackoverflow.com/questions/4472821/asp-net-mvc-3-rc-2-client-side-validation-with-globalization – DoctorMick Jul 12 '11 at 09:49

1 Answers1

0

but, you want to display the formatted number on the textbox or in a label?

Can a user add 50000 to the textbox and you show 50.000 after submit?

Either way, you have 2 choices:

Use "50000".ToString("N0"); to display 50.000 (or the correct way is saying that the number will be formatted according to the CurrentCulture applied, or use the Globalization in the client side

Scott Hanselman has a great article about it

balexandre
  • 73,608
  • 45
  • 233
  • 342