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

130
Vistas
get value from hidden field in view and use it within the same view

I have an MVC project where the model for the view page has several "layers" for lack of a better word.

The model has one main object (facility) and many related objects (doctors, locations, etc.)

All the data for the facility and the related objects is in the model when the view is loaded and is loaded using standard view notation.

@for (int Pro = 0;Pro < doctors.count; Pro++
{
    @Model.Facility.Doctor[Pro].FirstName
    @Model.Facility.Doctor[Pro].LastName
    @Model.Facility.Doctor[Pro].MiddleName
    ...
    <button data-id="Pro">Edit</button>      <--- loads the modal
}

where "Pro" is the loop iterator to display the information for each doctor

in the Modal, I have:

<input type="hidden" id="index" value="2">

which is set using Jquery and JavaScript, and I need to get that value for this:

@Model.Facility.doctor[index].degrees

to get the related object in the model for the modal.

Since that line is technically C# code, it does not directly have access to the hidden field - at least not anyway I have found.

Again, all the data is already in the model so there is no need for a postback or ajax call to get the data needed.

I would appreciate any suggestions to accomplish this.

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