本文介绍了ASP.NET MVC 3剃须刀 - 添加类EditorFor的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想一类添加到输入。
这是行不通的:
@ Html.EditorFor(X => x.Created,新{@class =日期})
解决方案
添加一个类 Html.EditorFor
无厘头作为模板里面你可以有很多不同的标签。所以,你需要的类分配编辑模板中:
@ Html.EditorFor(X => x.Created)
在自定义模板:
< DIV>
@ Html.TextBoxForModel(X => x.Created,新{@class =日期})
< / DIV>
I'm trying to add a class to an input.
This is not working:
@Html.EditorFor(x => x.Created, new { @class = "date" })
解决方案
Adding a class to Html.EditorFor
doesn't make sense as inside its template you could have many different tags. So you need to assign the class inside the editor template:
@Html.EditorFor(x => x.Created)
and in the custom template:
<div>
@Html.TextBoxForModel(x => x.Created, new { @class = "date" })
</div>
这篇关于ASP.NET MVC 3剃须刀 - 添加类EditorFor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!