How can I access JavaScript value inside @URL.Action()
? something like:
<script type="text/javascript"> function name(myjavascriptID) { jQuery("#list_d").jqGrid('setGridParam', { url: '@URL.Action("download file", "download", new { id = <myjavascriptID> })', page: 1 }); } </script>
You can concat the client-side variables with the server-side url generated by this method, which is a string on the output. Try something like this: var firstname = "abc"; var username = "abcd"; location. href = '@Url.
A URL action is a hyperlink that points to a web page, file, or other web-based resource outside of Tableau. You can use URL actions to create an email or link to additional information about your data. To customize links based on your data, you can automatically enter field values as parameters in URLs.
You can use this Url. Action("actionName", "controllerName", new { Area = "areaName" });
You can't. JavaScript doesn't execute when generating the action URL. What you can do, is do something like this:
function name(myjavascriptID) { var link = '@Url.Action("download file", "download", new { id = "-1" })'; link = link.replace("-1", myjavascriptID); jQuery("#list_d").jqGrid('setGridParam', { url: link, page: 1 }); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With