Display Annotation Custom Editor Grid Popup TagHelper Not Working

1 Answer 21 Views
Grid Template
Cynthia
Top achievements
Rank 1
Cynthia asked on 23 Dec 2025, 08:59 PM

I feel like this should be simple but I can't figure this out.  I use the  [Display(Name = "Code")] annotation in my view model. I have a simple custom editor popup on my grid.  I use taghelpers because I just do.  I am trying to get my labels to show the display name in my popup.  I have seen older posts where validation is also not working but I think this has been fixed.  Either way I feel like this should work.

Model

 public class ChargeViewModel

 {
     [ScaffoldColumn(false)]
     public int ChargesID { get; set; }

     [Required]
     [UIHint("EditChargePopup")]
     [Display(Name = "Code")]
     public string ChargesCodeID { get; set; }

Custom Editor

<div class="col-4">
    <label for="ChargesCodeID" />
    <kendo-textbox for="ChargesCodeID" />
</div>
<div class="col-4">
    <label for="Charges_Name" />
    <kendo-textbox for="Charges_Name" />
</div>
<div class="col-4">
    <label for="Charges_Fee" />
    <kendo-numerictextbox for="Charges_Fee" format="c2" decimals="2" />
</div>

Results

 

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 25 Dec 2025, 09:29 AM

Hello Cynthia,

The `for` attribute is not using the ASP.NET Core Label Tag Helper.

<label for="ChargesCodeID" />

To fix this, use the `asp-for`, not `for`.

<div class="col-4">
    <label asp-for="ChargesCodeID" class="form-label"></label>
    <kendo-textbox for="ChargesCodeID"></kendo-textbox>
    <span asp-validation-for="ChargesCodeID" class="text-danger"></span>
</div>

<div class="col-4">
    <label asp-for="Charges_Name" class="form-label"></label>
    <kendo-textbox for="Charges_Name"></kendo-textbox>
    <span asp-validation-for="Charges_Name" class="text-danger"></span>
</div>

<div class="col-4">
    <label asp-for="Charges_Fee" class="form-label"></label>
    <kendo-numerictextbox for="Charges_Fee" format="c2" decimals="2"></kendo-numerictextbox>
    <span asp-validation-for="Charges_Fee" class="text-danger"></span>
</div>

Make sure you have Tag Helpers enabled in the view (usually via _ViewImports.cshtml):

@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

Ensure your model properties also have [Display(Name="...")] where needed:

public class ChargeViewModel
{
    [ScaffoldColumn(false)]
    public int ChargesID { get; set; }

    [Required]
    [UIHint("EditChargePopup")]
    [Display(Name = "Code")]
    public string ChargesCodeID { get; set; }

    [Display(Name = "Name")]
    public string Charges_Name { get; set; }

    [Display(Name = "Fee")]
    public decimal? Charges_Fee { get; set; }
}

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Grid Template
Asked by
Cynthia
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
Share this question
or