TextBoxFor:
例如:
@Html.TextBoxFor(m => m.Title, new { @class = "FormTextBox" })
对应的是
<input class="FormTextBox" id="Keyword" name="Keyword" type="text" value="" />
EditorFor:
而则很不同:
虽然前台写的也是:
@Html.EditorFor(m => m.Title, new { @class = "FormTextBox" })
但需要在model中定义对应的数据类别,默认为 Text
当默认是与 TextBoxFor 相同,
[DataType(DataType.Text)] //可以省略
public string Title { get; set; }
结果为:
<input class="text-box single-line" id="Title" name="Title" type="text" value="" />