Pass js variable or inout value to razor
问题 Is it possible to pass js variable or html value to razor? @{ int n = ?????; Html.RenderPartial("_AddressBookEdit", @Model.Addresses[n]); } How can I set variable n from javascript or assign it a value from a hidden field? n = $('#myvar').val()'; The above code does not work. 回答1: You are missing a fundamental understanding here. I already answered a version of this question by you, however I did not think you misunderstood this point. You cannot pass anything from javascript to razor without