I have a jQuery script which let’s me search/filter through a list of people and select them. Using this, it allows me to set a div based on that person’s traits.
However, I need to be able to use this variable later on (after I post the form.)
Is there a way to set the model variable for the personID in the jQuery? i.e.:
<%: Model.PersonId == ui.item.id; %>
Or is there another way to do this?
Also – I am posting the form using a submit button, so if there was a way I could set Html.Hidden(), then that would work also.
You can create a hidden field using javascript, set its value with whatever value you need and then submit it along with the form. You can then access this hidden field value in your controller.
Alternatively
On the server side you can get this value using