using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
namespace secondMvc.MyControls
{
public static class CheckBoxList
{
public static MvcHtmlString CheckListBox(this HtmlHelper helper, string Name, Dictionary<Int32, string> citiesList, bool IsVertical, string cssClass)
{
StringBuilder sb = new StringBuilder();
sb.Append(string.Format("<div >"));
foreach (var item in citiesList)
{
sb.Append(helper.CheckBox(item.Value, true, new { @class = cssClass, value = item.Key }));
sb.Append(helper.Label("RadioButtonItems", item.Value));
sb.Append(" ");
if (IsVertical) sb.Append("<br>");
}
sb.Append("</div> ");
return MvcHtmlString.Create(sb.ToString());
}
}
}
System.Web.Mvc.HtmlHelper
' does not contain a definition for
CheckBox and no extension method
'CheckBox' accepting a first argument of type
'System.Web.Mvc.HtmlHelper'` 可以找到(您是否缺少 using 指令或程序集引用?)
我像这样更改 web.config:
<configuration>
<appSettings>
</appSettings>
<connectionStrings>
</connectionStrings>
<pages>
<namespaces>
<add namespace="secondMvc.MyControls"/>
</namespaces>
</pages>
<system.web>
<compilation>
<assemblies>
<add assembly="secondMvc.MyControls" />
</assemblies>
</compilation>
</system.web>
</configuration>
但我有同样的错误。任何的想法?