title: ASP.NET Core Razor Pages Keep Display Data on Postback
body: <p>I've read many questions/answers related to this, but I still feel like I'm missing something. I've dumb'd everything down a bit to make it easier to read, but essentially my issue is this -</p>
  
  <p>I have a razor page where the user can edit a company model. The user can only edit, let's say 1 field, which is the <code>company name</code>. However, I need to display about 20 different informative fields for that company. </p>
  
  <p>On postback, I check if my model is valid and if it isn't, I return <code>Page()</code>. The problem is all of my display data gets lost. That means that I have resorted to putting 20 different hidden inputs along with each property because I need it in case of a model error. </p>
  
  <pre><code>public async Task&lt;IActionResult&gt; OnPostAsync()
  {
       if (ModelState.IsValid)
       {
          //*** success - return user to a different page
       }
       return Page();
  }
  
  &lt;p&gt;@Model.Company.Location.Name&lt;/p&gt;
  &lt;form class="row" method="post"&gt;
      @Html.HiddenFor(m =&gt; m.Company.CompanyId)
      @Html.HiddenFor(m =&gt; m.Company.Location.Name)
      @Html.HiddenFor(m =&gt; m.Company.Location.City)
      @Html.HiddenFor(m =&gt; m.Company.Location.State)
      //*** more listed here
  
  
      @Html.DropDownListFor(m =&gt; m.Company.Name)
      &lt;input type="submit" value="Save" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>There's a bit of what my html looks like just so you get the idea. Do I really have to put all the label values in a hidden input to make sure I keep them in case of a model state error? </p>
  
  <p>Just looking for the best practice as this seems very...not correct.</p>