Home Additional attribute of the CSS-class type in my Tag-Helper
Reply: 0

Additional attribute of the CSS-class type in my Tag-Helper

Tomasz Wojciechowski
1#
Tomasz Wojciechowski Published in 2017-12-05 21:47:23Z

My tag-helper is placed in the DIV tag by itself. For DIV tag I set the CSS class by attribute DivClass (div-class):

public class MyTag : InputTagHelper
{
    public string DivClass { get; set; } = "form-group";
    public override void Process(TagHelperContext context, TagHelperOutput output)
    {
        output.TagName = "input";
        output.PreElement.AppendHtml($"<div class=\"{DivClass}\">");
        // ... adding other stuff (ex. Label, Validation)
        output.PostElement.AppendHtml("</div>");
        base.Process(context, output);
    }
}

<mytag class="form-control" div-class="form-group" />

The tag-helper works in general. But is there any possibility for the div-class attribute to display intellisense prompts, as for the class attribute?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.314117 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO