this wont work! its not self closing the html so the image never shows
[HtmlTargetElement("img", Attributes = "failure-count")]
public class StatusIconTagHelper : TagHelper
{
public int FailureCount { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
if (FailureCount==0)
{
output.Attributes.SetAttribute("src", "~/images/GreenTick.png");
}
else
{
output.Attributes.SetAttribute("src", "~/images/RedCross.png");
}
output.Attributes.SetAttribute("width", 22);
output.TagMode = TagMode.SelfClosing;
}
}
then in the view i have this
<img failure-count="@item.CurrentlyFailed" />
the resultant HTML is this:
<img src="~/images/GreenTick.png" width="22">
So its not closing the html even though its closed in the view and the TagMode=SelfClosing... anyone else seen this?