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.

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You probably meant EditorFor - also a solution. Glad it was helpful. Good luck.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.