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,