learning
learning

Reputation: 11725

How to pass a razor variable to jquery function as parameter

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

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

where I have

@{string Interest=""}

Upvotes: 4

Views: 8424

Answers (2)

kapsiR
kapsiR

Reputation: 3177

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.

Upvotes: 1

Atanas Korchev
Atanas Korchev

Reputation: 30661

You need to quote the string like this:

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

Upvotes: 6

Related Questions