Doubt with decimal numbers Asp.net mvc

Asked

Viewed 83 times

-1

I have a register, where I have some fields to enter values, but the same only accepting integer number, if add some value with decimal passes zero.

Controller

    [Display(Name = "Valor Multiplicador para Opção 01:")]
    [DisplayFormat(DataFormatString = "{0:0,0.00}", ApplyFormatInEditMode = true)]
    public double VALOR01 { get; set; }

View

<!-- language: lang-html -->    
 @using (Html.BeginForm("Index", "CadastroPossibilidade", FormMethod.Post))
 {

     <div class="row">
        <div class="container">

           <div class="col-md-3 form-group">
                @Html.HiddenFor(c => Model.IDPOSSIBILIDADE)
                @Html.LabelFor(c => Model.DESCRICAO01)
                @Html.TextBoxFor(c => Model.DESCRICAO01, new { placeholder = "descrição", @class = "form-control" })

           </div>

           <div class="col-md-3 form-group">
                @Html.LabelFor(c => Model.VALOR01)
                @Html.TextBoxFor(c => Model.VALOR01, new { placeholder = "0", @class = "form-control" })

           </div>


           <div class="col-md-3 form-group">
                @Html.LabelFor(x => x.IDTITULOPOSS)
                @Html.DropDownListFor(x => x.IDTITULOPOSS, ViewBag.TituloPos as SelectList, new { @class = "form-control" })
                @Html.ValidationMessageFor(x => x.IDTITULOPOSS)
           </div>

      </div>
    </div>
 }

1 answer

0

I made the change to

<div class="col-md-3 form-group">
<label>Multiplicador 01:</label>
<input class="form-control input-sm" autocomplete="off" type="number" ng-pattern="/^[0-9]+(\.[0-9]{1,2})?$/" step="0.01" id="valor1" name="valor1">
</div>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.