Thursday, May 23, 2024
 Popular · Latest · Hot · Upcoming
57
rated 0 times [  64] [ 7]  / answers: 1 / hits: 107872  / 13 Years ago, thu, june 23, 2011, 12:00:00

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>

More From » asp.net-mvc

 Answers
6

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 });
}

[#91539] Wednesday, June 22, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
rey

Total Points: 415
Total Questions: 100
Total Answers: 100

Location: Croatia
Member since Fri, Sep 11, 2020
4 Years ago
;