Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

369
Vistas
Update ASP.NET MVC Model value from javascript

In an ASP.NET MVC page, I'd like to change some valuee in the Model from javascript code when I click on an onClick button event.

I tried several solution but in any case the model is updated.

As exemple : In the model there are :

  • Firstname
  • LastName
  • Email.

In the razor page :

@Html.TextboxFor(model => model.LastName, new { id = "MyLastName" })

There is a button :

<button id="btnDelete" onclick="/*Code to update model*/ ">Click me</button>

In "Code to update model", I'd like change the model value for @Model.FirstName and @Model.Email via javascript.

I tried to assign Model.LastName to an HiddenFor :

@Html.HiddenFor(model => model.Lastname, new { id = "MyLastName" })

Get the value by javascript and change the value but the value in the Model is not updated.

Any idea ?

Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda