【发布时间】:2014-07-22 14:12:55
【问题描述】:
在我的 _Layout.cshtml 我有这个 html 代码
@using PreVenta
<li class="@Html.ActivePage("Home")">
<a href="@Url.Action("Index", "Home")">
<i class="fa fa-home"></i>
<span class="title">Home</span>
<span class="@Html.SelectedPage("Home")" />
</a>
</li>
我有一个助手来检测当前的活动页面
public static string ActivePage(this HtmlHelper helper, string controller)//, string action)
{
string classValue = "";
string currentController = helper.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString();
//string currentAction = helper.ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString();
if (currentController.ToLower() == controller.ToLower()) // && currentAction == action)
{
classValue = "start active";
}
return classValue;
}
主要问题是当我尝试启动 mi webapp 时,我收到此错误 编译器错误消息:CS1061:“System.Web.Mvc.HtmlHelper”不包含“ActivePage”的定义,没有扩展方法“ActivePage”接受类型为“System.Web”的第一个参数未找到。 Mvc.HtmlHelper '(您是否缺少 using 指令或程序集引用?)。
请一些可以帮助我,因为我很困惑。谢谢
【问题讨论】:
-
@using PreVenta 表示您正在添加命名空间。 PreVenta 是有效的命名空间吗?
-
你也应该显示你的命名空间声明
-
命名空间是命名空间 PreVenta。帮助文件位于 App_start 文件夹中
-
你能展示完整的课程吗?
标签: c# asp.net-mvc asp.net-mvc-4 razor