How to get javascript variable in URL. Action mvc method

onSelectRow: function(id) { document.location.href = '@Url.Action("EditEncounter", "EditEncounter", new { encounterId = "'<%:id%>'", popId = TempData["POPULATIONID"] })' //new { encounterId = temp.EncounterId, popId = (int)TempData["POPULATIONID"] } } 

How on my own hill do I get this id variable in my Url.Action method?

This is what I look when I debug

 document.location.href = '/EditEncounter/EditEncounter?encounterId=%40id&amp;popId=2' 
+4
source share
1 answer
 var dummyURL ='@Url.Action("EditEncounter", "EditEncounter", new { encounterId = -2, popId = TempData["POPULATIONID"] })'; var path =dummyURL.replace("-2", id); debugger; document.location.href = path; 

It works.

+4
source

All Articles