Gordana Tasic

Gordana Tasic

  • 2.1k
  • 81
  • 9.7k

How to use localizer in <label> tag?

Jan 26 2023 12:57 AM


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">

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>


Answers (1)