1

I have a currency Model decorated with [DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:c}")], it does work (The $ sign is displayed) for DisplayFor, but not for TextBoxFor in the View.

May be this is a wrong approach for this case and I'd rather go with some JQuery solution, but I am wondering if there's a "framework way"...

Thanks in advance.

tereško
  • 58,060
  • 25
  • 98
  • 150
LazyZebra
  • 1,097
  • 16
  • 24

1 Answers1

1

You can define EditorTemplate for TextBox and override its behavior any way you want, in your example just to show it as currency (if I understood your motives correctly). I think its simpler than jQuery and its a "framework way" as you called it.

There is great example on how to do it here: Currency Formatting MVC

Hope this helps, please let me know if not.

Community
  • 1
  • 1
Display Name
  • 4,672
  • 1
  • 33
  • 43