【问题标题】:The name 'Url' does not exist in the current context error in asp.netasp.net 中的当前上下文错误中不存在名称“Url”
【发布时间】:2012-01-22 13:35:08
【问题描述】:

我在 asp.net 页面中有以下代码行:

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

在 document.read (javascript) 中,但是当我尝试编译时,Visual Studio 抛出了一个错误:

错误 2 当前上下文中不存在名称“Url”

任何想法为什么会发生这种情况?

【问题讨论】:

  • 您使用的是 ASP。 NET MVC 2 ?

标签: javascript asp.net asp.net-mvc url.action


【解决方案1】:

您使用的是哪个版本的 MVC?您使用的是 Web 表单还是 Razor 视图?

剃刀语法

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

【讨论】:

    【解决方案2】:

    asp.net forums 出现明显相同的错误。您的应用中是否引用了 system.web.mvc?

    【讨论】:

      猜你喜欢
      • 2015-01-29
      • 2013-06-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多