I am working on an MVC2 appication
I have data encryption I use (both client side and server side) in my model there are several fields which allow only decimal values as soon as a user types a decimal values, I want to convert it to a more readable format to be done. For example, 1200 should be formatted as 1,200, while the 500 should be in the form of it as it is.
This is my model:
Public Virtual Grossfi? Charge {receives; Set; } And here's how it works:
%: HTML Textbox (Model = & gt; Model. Grease)% & gt; Any thoughts about this would be highly appreciated.
Thank you!
Instead Html.TextBoxFor you Html.EditorFor and respect the data annotation in this way: Model:
(I do not know that grosephie? , But gives a decimal value of it) [DisplayFormat (DataFormatString = "{0: 0,0}")] Public Virtual Decimals? Charge {receives; Set; } See:
Html.EditorFor (model => model.GrossFee) you too It is possible to zoom HtmlEncode and ApplyFormatInEditMode to suit your particular application.
Anything that is recorded (such as IE before the post-back), converts the text box contents into a comma group number, it must be javascript based.
Comments
Post a Comment