title: How can I make my EditorFor disabled?
body: <p>I have an MVC Razor <em>Create</em> view and my model contains one or more fields that need to be auto-filled by the system, such as "Timestamp" and "Username". Because these fields are required, they need to be in the form.</p>
  
  <p>Here is an example of what the default code looks like when you allow Visual Studio to scaffold your views from a controller. </p>
  
  <pre><code>        &lt;div class="form-group"&gt;
          @Html.LabelFor(model =&gt; model.RoseUserName, 
              htmlAttributes: new { @class = "control-label col-md-2" })
          &lt;div class="col-md-10"&gt;
              @Html.EditorFor(model =&gt; model.RoseUserName, 
                    new { htmlAttributes = new { @class = "form-control" } })
              @Html.ValidationMessageFor(model =&gt; model.RoseUserName, "", 
                    new { @class = "text-danger" })
          &lt;/div&gt;
      &lt;/div&gt;
  </code></pre>
  
  <p>This what the code looks like when rendered. It's functional, but the first and third fields are fully editable when it shouldn't be. So the question is how we can have EditorFor fields that feed the correct data into the model when the form is submitted but that the user can't change?</p>
  
  <p><img src="https://i.stack.imgur.com/1ZNBr.png" alt="This is what the default Create form looks like"></p>
  
  <p><strong>Further Explanation</strong>
  While there are some reasons you might want to keep those fields hidden from view, there are also valid reasons you would want these fields to be seen by the user, such as in a company intranet with users who expect to see that information. While a datestamp could be autogenerated by SQL Server with a <code>getdate()</code> default value, capturing the user's identity under Windows Authentication would need to be done from from the MVC side. The identification of the user is part of the model.</p>