Separator of thousands

Asked

Viewed 446 times

2

How could you put thousands apart into one textBoxFor()?

Example:

Value entered in View 1,321 ( The point is for visual ease only) controller would receive the 1321 value to insert into the base.

My field and Intand use the ValidationMessageFor(). When I point it returns the error because it has a point.

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");
}
  • 1

    Enter the code so we can see how it is. Especially what control you’re using. This point is thousand separation?

  • Put the code there.

  • bigown, the point I just want to show visually because users are saying it’s bad to visualize without the point , I added the codes was what you needed ?

1 answer

2

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

Html.EditorFor(model => model.contatoEfeitvo)

I find this control even better.

There in the model use on the property of contatoEfeitvo:

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

I put in the Github for future reference.

The other forms seem to me gambiarra.

  • bigow, Thanks for the help, but it didn’t work = Following its logic I did so, @Html.Texboxfor(model => model.contactEfeitvo , "{0:N0}") [Displayformat(Dataformatstring = "{0:N0}")] all right. But when I go to update it complains of the point.!

  • The question does not have enough details to give a complete solution. I did what I could with what I had.

  • Thank you. His mode gave me the idea, with decimal field 18,0 it works normal in its form ( I already do this with monetary {0:n} ) I will look because the int field does not work.!

  • @Edgararaujo the answer to your question?

Browser other questions tagged

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