Search code examples
javascriptasp.netasp.net-mvcurl.action

The name 'Url' does not exist in the current context error in asp.net


I have the following line of code in an asp.net page:

$("#example").editable('<%=Url.Action("UpdateSettings","Admin") %>');

In document.read (javascript), but visual studio throwns an error when I try to compile it:

Error 2 The name 'Url' does not exist in the current context

Any ideas why this would happen?


Solution

  • What version of MVC are you using? Are yo using web forms or razor views?

    Razor Syntax

    $("#example").editable('@Url.Action("UpdateSettings","Admin")');