Can I use a Tag Helper in a custom Tag Helper that returns html?

No you cannot. TagHelpers are a Razor parse time feature. One alternative is creating a TagHelper and manually invoking its ProcessAsync/Process method. Aka: var anchorTagHelper = new AnchorTagHelper { Action = “Home”, }; var anchorOutput = new TagHelperOutput(“a”, new TagHelperAttributeList(), (useCachedResult, encoder) => new HtmlString()); var anchorContext = new TagHelperContext( new TagHelperAttributeList(new[] { new TagHelperAttribute(“asp-action”, … Read more

Set Default/Null Value with Select TagHelper

You can just insert an option item inside the select: <select asp-for=”Category” asp-items=”@ViewBag.Category” class=”form-control”> <option disabled selected>— SELECT —</option> </select> The disabled keyword in the code above means that the “— SELECT —” row cannot be picked again once a choice has been selected in the list. If you want the user to be able … Read more

asp.net conditionally disable a tag helper (textarea)

It is actually very simple, the disable attribute is already working as you want – you can pass in a boolean value: <textarea asp-for=”Doc” disabled=”@Model.MustDisable”></textarea> if false the disabled attribute is not rendered: <textarea></textarea> if true the disabled attribute is set to “disabled”: <textarea disabled=”disabled”></textarea>

tech