In our project we are using TextBoxFor in many places. We would like to set the height and width of the TextBoxFor wherever we have used, for that we have done this.
<%= Html.TextBoxFor(x => x, new { @class = "TextBoxFor" } ) %>
.TextBoxFor
{
height:30px;
width:250px;
font-family:@Batang;
font-size:20px;
font-weight: bold;
}
有可能将<代码>和t;%=Html.TextBoxFor(“”)、新的{@class = “TextBoxFor”} %>在编辑/显示Template和我们刚才呼吁的其他地点的某些地方
<%= Html.TextBoxFor(x => x) %>
Which means we are not specifying the css class name. So it is easy to maintain. Any ideas. Thanks
最新消息说,我设立了一个静态帮助者,但也有错误。
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) %>
任何想法?