Nameandidprovider does not find reference in the class context - ASP.NET Core MVC

Asked

Viewed 12 times

0

I need to do a custom implementation for the input field, so I created the following class:

[HtmlTargetElement("input", Attributes = "tm-for", TagStructure = TagStructure.WithoutEndTag)]
public class TmInputTagHelper : InputTagHelper
{
    
    public TmInputTagHelper(IHtmlGenerator generator) : base(generator)
    {            
    }

    [HtmlAttributeName("tm-for")]
    public ModelExpression TmFor
    {
        get => For;
        set => For = value;
    }

    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        base.Process(context, output);


        string fullName = NameAndIdProvider.GetFullHtmlFieldName(ViewContext, For.Name);

        if (ViewContext.ViewData.ModelState.TryGetValue(fullName, out var entry) && entry.Errors.Count > 0)
        {
            output.AddClass("is-invalid", HtmlEncoder.Default);
            output.RemoveClass("input-validation-error", HtmlEncoder.Default);
        }
    }
}

However, I cannot find the reference for this class: Nameandidprovider:

string fullName = NameAndIdProvider.GetFullHtmlFieldName(ViewContext, For.Name);

inserir a descrição da imagem aqui

I have the following usings:

using Microsoft.AspNetCore.Mvc.TagHelpers;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System.Text.Encodings.Web;

Well, I don’t know how I can get past that!

  • this class is internal and is not available for programming. example of class implementation: https://github.com/aspnet/Mvc/blob/master/src/Microsoft.AspNetCore.Mvc.ViewFeatures/NameAndIdProvider.cs

  • what the variable fullname makes? has an error in the code also in the base base.process have to check where to stay!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.