开发者

How to pass a razor variable to jquery function as parameter

开发者 https://www.devze.com 2023-02-14 18:27 出处:网络
I am having the following piece of code that is not working: <开发者_运维问答;a href=\"#\" onclick=\"Edit(@Interest);\">edit</a>

I am having the following piece of code that is not working:

<开发者_运维问答;a href="#" onclick="Edit(@Interest);">edit</a>

where I have

@{string Interest=""}


You need to quote the string like this:

<a href="#" onclick="Edit('@Interest');">edit</a>


If you want to call a method e.g. @Url.Action("test") for an action link, then you have to use it like:

<a href='@(Url.Action("test"))'>test</a>

Otherwise korchev's solution is right.

0

精彩评论

暂无评论...
验证码 换一张
取 消