2014-10-15 1 views
0

다음 코드를 사용하여 EditBlockFor라는 HTMLHelper 메서드를 만들려고합니다. 모델을 가져 와서 매번 할 필요없이 한 번에 LabelFor 및 EditorFor를 만듭니다. 내가 HtmlHelp를 제대로 전달하고 있다고 생각할 때 helper.LabelFor에서 HtmlString을 가져올 시간이 왔을 때 사용할 수있는 LableFor 메서드가 없습니다. 내가 여기서 무엇을 놓치고 있니?일반적인 패턴을 래핑하기 위해 HtmlHelper를 만들려고합니다.

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

namespace MyTest.Code 
{ 
    public static class HtmlHelperExtensions 
    { 
    public static IHtmlString EditBlockFor<T> 
    (
    this HtmlHelper<T> helper, 
    Expression<System.Func<T, String>> prop, 
    Dictionary<String, Object> htmlAttributes = null 
    ) 
     { 
      HtmlString label; 
      HtmlString item; 


      label = helper.LabelFor(prop, htmlAttributes); 
      item = helper.EditorFor(prop, htmlAttributes); 

      return new HtmlString(label+" "+item); 
     } 
    } 
} 

답변

0

하나가

System.Web.Mvc.Html를 사용하여 포함 잊어 버렸;

관련 문제