Thousands separator

0

How could I put thousands separator in a textBoxFor() ?

Example:

Value entered in View 1.321 (The point is only to facilitate visually) and the controller would receive the value 1321 to insert into the base.

My field is Int and I use ValidationMessageFor() . When I put the point it returns the error by the fact that it has a dot.

Codes:

View

@Html.TextBoxFor(model => model.contatoEfeitvo)
@Html.ValidationMessageFor(model => model.contatoEfeitvo)

Controller

if (ModelState.IsValid)
{
   indicadoresmassivosp.status = (TempData["status"] ?? "2").ToString();
   indicadoresmassivosp.dataAtualizacao = DateTime.Now;
   indicadoresmassivosp.idUsuario = usuario.UsuarioId;
   db.Entry(indicadoresmassivosp).State = EntityState.Modified;
   db.SaveChanges();
   return RedirectToAction("Index");
}
    
asked by anonymous 21.12.2015 / 18:21

1 answer

1

If you can change the control you can use this in view :

Html.EditorFor(model => model.contatoEfeitvo)

I find this control even better.

Here in model uses the property of contatoEfeitvo :

[DisplayFormat(DataFormatString = "{N0}")]

The other forms seem to me to be gambiarra.

    
21.12.2015 / 18:44