우리 프로젝트에서 우리는 여러 곳에서 TextBoxFor를 사용하고 있습니다. TextBoxFor의 높이와 너비를 우리가 사용한 곳마다 설정하고 싶습니다.EditorTemplate 또는 DisplayTemplate에서 TextBoxFor
<%= Html.TextBoxFor(x => x, new { @class = "TextBoxFor" }) %>
.TextBoxFor
{
height:30px;
width:250px;
font-family:@Batang;
font-size:20px;
font-weight: bold;
}
는 것이 가능 EditorTemplate/DisplayTemplate 어딘가에 <%= Html.TextBoxFor("", new { @class = "TextBoxFor" }) %>
을 넣어하고 다른 장소에서 우리는 단지 우리가 CSS 클래스 이름을 지정하지 뜻이
<%= Html.TextBoxFor(x => x) %>
처럼 전화입니다. 따라서 유지 관리가 쉽습니다. 아이디어가 없습니다. 감사합니다
업데이트, 나는 정적 도우미를 생성하지만 오류를 데 ..
public static MvcHtmlString CustomTextBoxFor<TModel, TProperty>(this HtmlHelper<TModel> htmlHelper, Expression<Func<TModel, TProperty>> expression, object htmlAttributes)
{
return htmlHelper.CustomTextBoxFor<TModel, TProperty>(expression, new { @class = "TextBoxFor" });
}
<%: Html.CustomTextBoxFor(m => m.Name) %>
어떤 아이디어가?
무한 루프를 생성하는 자신을 반환 할 수 없습니다. 'htmlHelper.TextBoxFor'로 변경하십시오. –