Pass a javascript variable as parameter to @url.Action()

You need to build you url using javascript/jquery. In the view change the link to <a id=”export” href=#”>Export as CSV</a> Then in the script var baseurl=”https://stackoverflow.com/questions/30731582/@Url.Action(“Export”)”; $(‘#export’).click(function() { var url = baseurl + ‘?SelectedAccountType=” + $(“#SelectedAccountType’).val() + ‘&FromDate=” + $(“#FromDate’).val() + ‘&ToDate=” + $(“#ToDate’).val() + …etc location.href=url; }); However if your form is marked with … Read more

Url.Action parameters?

The following is the correct overload (in your example you are missing a closing } to the routeValues anonymous object so your code will throw an exception): <a href=”https://stackoverflow.com/questions/6278694/<%: Url.Action(“GetByList”, “Listing”, new { name = “John”, contact = “calgary, vancouver” }) %>”> <span>People</span> </a> Assuming you are using the default routes this should generate the … Read more