title: How to set a default value for a hidden field?
body: <p>im working in a project that creates 2 types of users: admin and member. To differenciate them i have set a <em>bool</em> value, <em>true => admin ||  false => member</em>.</p>
  
  <p>Only admins can create admins, if an anon user tries to create an account, the default value for that field needs to be <em>false</em>. I have set a <em>@html.HiddenFor</em> in that field, but its sending a null value so the model can't be saved in the database.</p>
  
  <p>this is the code:</p>
  
  <pre><code>[HttpPost]
  [ValidateAntiForgeryToken]
  public ActionResult Registro(
          [Bind(Include="Id,Login,Pass,Nombre,Apellido,Rol")]Usuario objUser)
  {
      //somecode
  
      var errors = ModelState.Values.SelectMany(v =&gt; v.Errors);
      //error shows the null 'rol' parameter
      if (ModelState.IsValid)
      {
          db.Usuario.Add(objUser);
          db.SaveChanges();
          return RedirectToAction("Login");
      }
  
      return View(objUser);
  }
  </code></pre>
  
  <p>Razor:</p>
  
  <pre><code>@using (Html.BeginForm())
  {
      @Html.AntiForgeryToken()
      @Html.HiddenFor(model =&gt; model.Rol)
  
      //some inputs for the other fields
  }
  </code></pre>
  
  <p>Haven't found info related to that
  is it possible or do i need to do something else?</p>