Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><strong>1.</strong></p> <ul> <li><code>@Html.EditorFor(m =&gt; m)</code> - display editor for whole model</li> <li><code>@Html.EditorFor(m =&gt; m.propertyName)</code> - display editor for specific property of model </li> </ul> <p><strong>2.</strong></p> <p><code>@Html.EditorFor(m =&gt; m)</code> is equal to <code>@Html.EditorFor(t =&gt; t)</code> or <code>@Html.EditorFor(randomName =&gt; randomName)</code>. Name doesn't matter, it is just parameter's name. The type for this parameter is type of view model. </p> <p>You have to pass function, because it is not only value, that counts. Reflections are used to get attributes, that describe how to display property. Look at this example</p> <pre><code>public class ResetPasswordModel { public string Username { get; set; } [DataType(DataType.Password)] public string NewPassword { get; set; } [DataType(DataType.Password)] public string PasswordConfirmed { get; set; } } </code></pre> <p>Attributes describe, that NewPassword should be password field, not regular input. If we passed value, that would not be possible.</p> <p>In our example <code>@Html.EditorFor(m =&gt; m)</code> will show for containing one input for user name and two password inputs for passwords. <code>@Html.EditorFor(m =&gt; m.NewPassword)</code> will show input, which has type of password.</p> <p><strong>3.</strong></p> <p><code>http://msdn.microsoft.com/en-us/library/ee402949.aspx</code></p> <pre><code>public static MvcHtmlString EditorFor&lt;TModel, TValue&gt;( this HtmlHelper&lt;TModel&gt; html, Expression&lt;Func&lt;TModel, TValue&gt;&gt; expression ) </code></pre> <p>This is extension method for HtmlHelper class. <code>this HtmlHelper&lt;TModel&gt; html</code> is not a parameter, it is type of class, that function extends.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload