안녕하세요, HTML 도우미 methos 및 asp.net MVC 프로젝트를 만들려고하고 있지만이 오류가 발생하는 메서드를 호출 할 때 뭔가 잘못하고 있어야합니다 :확장 메서드를 만들면 오류가 발생합니다
나는 도이 나는 무엇@Html.LabelSomething("fsaf" , "ddada")
을 :
public static class Pager
{
public static string LabelSomething(this HtmlHelper helper, string target , string text){
return string.Format("<label for='{0}'>{1}</label>", target, text);
}
}
이 내가 그것을 호출하는 tryed 방법입니다
Error 1 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'LabelSomething' and the best extension method overload 'TestProject.Modules.Pager.LabelSomething(System.Web.WebPages.Html.HtmlHelper, string, string)' has some invalid arguments d:\Training\Practis.Internship.Workspace\Alex.Nistor\ADO.NET\TestProject\Views\Home\Index.cshtml 35 6 ADO.NET
Error 2 Instance argument: cannot convert from 'System.Web.Mvc.HtmlHelper' to 'System.Web.WebPages.Html.HtmlHelper' d:\Training\Practis.Internship.Workspace\Alex.Nistor\ADO.NET\TestProject\Views\Home\Index.cshtml 35 6 ADO.NET
이 내 코드입니다 틀렸어?
클래스의 네임 스페이스는 무엇입니까? –
네임 스페이스가 바깥 쪽이면 web.config에서 네임 스페이스를 views 폴더로 가져와야합니다 –