Net MVC中TextBoxFor与EditorFor的区别

一、TextBoxFor说明

如: @Html.TextBoxFor(m => m.Title, new { @class = “mytext” })

生成的HTML代码是:

二、EditorFor说明

EditorFor写法同上TextBoxFor,如下:

@Html.EditorFor(m => m.Title, new { @class = “mytext” })

但EditorFor需要在model中定义对应的数据类别,默认为 Text,默认是与TextBoxFor相同

[DataType(DataType.Text)] //可以省略
public string Title { get; set; }

生成的HTML代码如下:


这里写图片描述
个人微信公众号,欢迎大家关注。

扫描二维码关注公众号,回复: 9052085 查看本文章
发布了210 篇原创文章 · 获赞 34 · 访问量 44万+

猜你喜欢

转载自blog.csdn.net/u011872945/article/details/81514200