Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
586 views
Welcome To Ask or Share your Answers For Others

1 Answer

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...