Use JQuery variable inside of ASP.NET MVC Action link -


i want use jquery variable/value in asp.net mvc action link, need use $("#jobgr :radio:checked").val() in below line of code :

     @html.actionlink("insert", "insertpersonjob","reg" , new {jobno=$("#jobgr :radio:checked").val(), personid=user.identity.name },null) 

i receive error on $ , please me how can solve issue.

you can't use dynamic javascript inside actionlink, because actionlink generation in render html action.

but can use placeholder:

<a href="#" data-url="@html.actionlink("insert", "insertpersonjob","reg" , new { jobno="{replaceme}", personid=user.identity.name },null)" class="replacedlink">link</a>  <script>  $("a.replacedlink").click(function(){    window.location = $(this).attr("data-url").replace("{replaceme}", $("#jobgr :radio:checked").val()); });  </script> 

Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -