Tan*_*ash 3 c# asp.net-mvc asp.net-mvc-4
它们在网页上看起来都看起来很相似,但每个HTML的HTML都差别很大:
<input id="TEST" name="TEST" type="text" value="this one's filled in, but editor isn't">
<input class="text-box single-line" id="TEST" name="TEST" type="text" value="">
Run Code Online (Sandbox Code Playgroud)
该文档说Returns an HTML input element for each property in the object that is represented by the expression.的Html.Editor
虽然Html.TextBox说Returns a text input element by using the specified HTML helper and the name of the form field.
这是否意味着您将模型的字符串名称传递给Html.Editor它,然后它将为每个属性创建一个文本输入,而这Html.TextBox只是一个愚蠢的文本输入,在幕后没有别的东西?
HTML.Textbox:
使用指定的HTML帮助程序和表单字段的名称返回文本输入元素.
HTML.Editor:
此方法根据正在呈现的属性的数据类型以及是否使用某些属性标记属性,生成不同的HTML标记.
如果属性类型为基本类型(整数,字符串等),则该方法会为文本框呈现HTML输入元素.
如果属性标记有data-type属性或UIHintAttribute属性,则该属性指定为该属性生成的标记.例如,如果属性使用MultilineText属性标记,则该方法会为多行文本框生成标记.