How to use function parameter on @Url.Action Parameter

23 Views Asked by At

Url.Action parameter name as a function parameter. Here i use actionNameParameter as a function parameter now how i write this parameter on url: '@Url.Action(actionNameParameter)' I tried this code but it does not work. But i write like url:'@Url.Action("StringactionName")' then it works. But i need to use the function parameter as @Url.Action(actionNameParameter)

function example(actionNameParameter) {
        $.ajax({
            type: 'POST',
            url: '@Url.Action(actionNameParameter)'
        });
    }
1

There are 1 best solutions below

0
LDS On

hi can use escape sequence for single code 

 var actionNameParameter = "\'" + "@Url.Action(actionNameParameter)" + "\'";