I have a custom tag helper defined like so:
public class TextQuestionTagHelper : TagHelper
{
private readonly HtmlHelper _htmlHelper;
[HtmlAttributeName("asp-for")]
public ModelExpression For { get; set; }
public string Question { get; set; }
public string Description { get; set; }
public string Image { get; set; }
public TextQuestionTagHelper(IHtmlHelper htmlHelper)
{
_htmlHelper = htmlHelper as HtmlHelper;
}
public override async Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
{
var partial = await _htmlHelper.PartialAsync(
"Tags/TextQuestion",
new TextQuestionViewModel
{
Question = Question,
Description = Description
});
}
}
In the template Tags/TextQuestion I have:
@model TextQuestionViewModel
<p>@Model.Question</p>
<p>@Model.Description</p>
@Html.TextBoxFor(m => m)
Notice how I have a property For I'm wondering how to do I map this to the TextBoxFor inside my custom template and then render that view for the tag helper? I can't find any examples online
First define your taghelper
Then in the model
In the view
Remember to add the taghelper in _ViewImports
The input limit is set
And the page