1
I am customizing the user registration part using the Entity Framework Identity tool.
So on the registration page, I added a ComboBox
(Select in HTML):
Part of my View:
<div class="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 defined the "Department" field as required (mandatory):
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 if I select the department is as if it is blank:
Friend, what’s the difference between the two?
– Thomas Erich Pimentel
None because the code that will be sent to the browser will be the same, the question is to follow the pattern, in this case it is developing with the
Razor
other tags, so in my opinion better continue following.– Lucas Lopes