javascript - use Url.Action with dynamic values -


i have following link

var selectedvalue = "somedynamicvalue"; var selectedid = 100; window.location.href = '/home/' + selectedvalue + '/' + selectedid; 

how can use @url.action instead of above link generation?

i this:

var selectedvalue = "somedynamicvalue"; var selectedid = 100; var href = '@url.action("index", "home", new { selectedvalue = "_selectedvalue_", selectedid = "_selectedid_"})'; href = href.replace('_selectedvalue_', selectedvalue); href = href.replace('_selectedid_', selectedid); window.location.href = href; 

Comments