Gordana Tasic

Gordana Tasic

  • 1.6k
  • 96
  • 13.7k

How to use localizer in <label> tag?

Jan 26 2023 12:57 AM

Hi,

does anyone know how to use localizer instance within <label> tag? I tried this, but it doesn't work properly:

<div class="form-group">
            <label asp-for="@localizer["Year"]" class="control-label"></label>
            <input asp-for="@localizer["Year"]" class="form-control" />
            <span asp-validation-for="@localizer["Year"]" class="text-danger">
</div>

Here is the code:

@inject Microsoft.AspNetCore.Mvc.Localization.IViewLocalizer localizer

@{
    ViewData["Title"] = "Create";
}

<div class="form-group">
            <label asp-for="" class="control-label"></label>
            <input asp-for="" class="form-control" />
            <span asp-validation-for="" class="text-danger"></span>
</div>

 


Answers (1)