Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!