To display HTML in my edit view, I use helper @Html.EditorForModel()
.
My model:
[Required(ErrorMessage = "Campo obrigatório")] [Display(Name = "Nome completo")] public string Name { get; set; } [Required(ErrorMessage = "Campo é obrigatório")] [StringLength(100, ErrorMessage = "A {0} deve ter pelo menos {2} characteres.", MinimumLength = 6)] [DataType(DataType.Password)] [Display(Name = "Senha")] public string Password { get; set; } [DataType(DataType.Password)] [Display(Name = "Confirmar senha")] [Compare("Password", ErrorMessage = "A nova senha ea confirmação da senha não conincidem.")] public string ConfirmPassword { get; set; } [Required(ErrorMessage = "Campo obrigatório")] [Display(Name = "Convidado")] [UIHint("IsGuest")] public bool IsGuest { get; set; } [RequiredIf("IsGuest", true, ErrorMessage = "Campo é obrigatório")] [ScaffoldColumn(false)] public string CodeGuest { get; set; }
Property: CodeGuest
should not be created by the @Html.EditorForModel()
. (I would like to create it manually.)
Reading on the Internet, I found a few points and would like to know the difference.
Remembering that I do not want this to be hidden, this field will only be created by this
EditorTemplates (IsGuest.cshtml):
@using BindSolution.AndMarried.Model; @model BindSolution.AndMarried.Models.RegisterModel @Html.EditorFor(e => e.IsGuest) <span>TESTE</span> @Html.EditorFor(e => e.CodeGuest)
Question:
What is the difference between: [ScaffoldColumn (false)]
and [Display (AutoGenerateField = false)]
Why can't I do [Display (AutoGenerateField = false)] have the effect: 'do not generate the HTML field when calling
@ Html.EditorForModel () `.
source share