I am having difficulty working with monetary values (decimals), using web application, asp.net MVC
, with database Mysql . The problem is that I can not edit decimal values, such as: 53.50 , or 53.50 . I can not save using dot, not comma. The problem is also that web.config is already configured globalization with en .
Follow the model:
[DisplayName("Preço:")]
[DisplayFormat(ApplyFormatInEditMode = true, DataFormatString = "{0:C}")]
public Nullable<decimal> preco { get; set; }
Follow the view:
<div class="form-group">
@Html.LabelFor(model => model.preco, htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.preco, new { htmlAttributes = new { @class = "form-control", @placeholder = "somente numeros" } })
@Html.ValidationMessageFor(model => model.preco, "", new { @class = "text-danger" })
</div>
</div>
Web.config:
<system.web>
<globalization culture="pt-BR" uiCulture="pt-BR" />
...
</system.web>