Razor HTML助手类-can';t访问标准HTML帮助程序

Razor HTML助手类-can';t访问标准HTML帮助程序,razor,html-helper,Razor,Html Helper,我试图创建一个HTML帮助程序,以某种方式显示下拉框 我已经开始创建这样一个: using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Web; using System.Web.Mvc; namespace uQuiz.WebUI { public static class HtmlHelpers {

我试图创建一个HTML帮助程序,以某种方式显示下拉框

我已经开始创建这样一个:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;

namespace uQuiz.WebUI
{
    public static class HtmlHelpers
    {

        public static  MvcHtmlString TimerMinuteSelectBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression)
        where TModel : class
        {
            // Error, no definition
            htmlHelper.DropDownBoxFor();
        }
    }
}
使用系统;
使用System.Collections.Generic;
使用System.Linq;
使用System.Linq.Expressions;
使用System.Web;
使用System.Web.Mvc;
命名空间uquick.WebUI
{
公共静态类HtmlHelpers
{
公共静态MvcHtmlString TimerMinuteSelectBoxFor(此HtmlHelper HtmlHelper,表达式)
其中TModel:class
{
//错误,没有定义
htmlHelper.DropDownBoxFor();
}
}
}
但是
htmlHelper
不包含
DropDownBoxFor()
或任何其他标准Html帮助程序的定义,如
TextBoxFor()

错误1“System.Web.Mvc.HtmlHelper”不包含 “DropDownBoxFor”的定义,无扩展方法 “DropDownBoxFor”接受类型为的第一个参数 可以找到“System.Web.Mvc.HtmlHelper”(您是否缺少 使用指令或程序集 参考?)

我看到他们可以在这个答案中访问它,但我不能


如何访问中的标准HTML帮助程序。

您需要添加对
System.Web.Mvc.HTML

public static  MvcHtmlString TimerMinuteSelectBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, ....
{
  MvcHtmlString dropdown = SelectExtensions.DropDownListFor(helper, expression, ....
public static MvcHtmlString TimerMinuteSelectBoxFor(此HtmlHelper HtmlHelper,…)。。。。
{
MvcHtmlString dropdown=SelectExtensions.DropDownListFor(helper,expression,…)。。。。