1.4.2.Labels

  • 2 choices to change the label display:

    • 1.use data annotation

      [Display(Name = "Date or Birth")]
      public string Birthday { get; set; }
    • 2.Use HTML

      @using (Html.BeginForm("Create", "Customers"))
      {
      <div class = "form-group">
        @Html.LabelFor(m => m.Name)
        @Html.TextBoxFor(m => m.Name, new {@class = "form-control"})
      </div>
      <div class="form-group">
        <label>Date of Birth</label>
        @Html.TextBoxFor(m => m.Birthday, new { @class = "form-control" })
      </div>
      <div class="checkbox">
        <label>
            @Html.CheckBoxFor(m => m.IsSubscribeToNesletter) Subscribed to Newsletter
        </label>
      </div>
      }

Last updated