I'm customizing the user registry part, using the Entity Framework's Identity Tool.
Then on the registration page, I added a ComboBox
(Select in HTML):
PartofmyView:
<divclass="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Departamento, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
<select class="form-control" id="select">
<option>Administração</option>
<option>Produção</option>
<option>Vendas</option>
<option>Comercial</option>
<option>Compras</option>
<option>Qualidade SGQ</option>
<option>Qualidade Inspeção</option>
<option>Engenharia</option>
<option>Serviços</option>
<option>Desenvolvimento</option>
<option>Marketing</option>
<option>T.I</option>
</select>
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Telefone, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Telefone, new { @class = "form-control" })
</div>
</div>
And I set the "Department" field as required (required):
public class RegisterViewModel
{
[Required]
[Display(Name = "Usuario")]
public string Usuario { get; set;}
[Required]
[Display(Name = "Nome")]
public string Nome { get; set; }
[Required]
[Display(Name = "Sobrenome")]
public string Sobrenome { get; set; }
[Required]
[Display(Name = "Departamento")]
public string Departamento { get; set; }
[Display(Name = "Telefone")]
public string Telefone { get; set; }
[Required]
[EmailAddress]
[Display(Name = "Email")]
public string Email { get; set; }
[Required]
[StringLength(100, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 6)]
[DataType(DataType.Password)]
[Display(Name = "Password")]
public string Password { get; set; }
[DataType(DataType.Password)]
[Display(Name = "Confirm password")]
[Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
public string ConfirmPassword { get; set; }
}
However, when trying to register the new user, even when I select the department, it is as if it were blank: