MVC 6 Tag Helper を使用して独自のアンカー タグを作成しました。プロパティから innerHtml を指定すると問題なく動作しますが、HTML から直接 innerHtml を指定したいと考えています。カスタム アンカーの TagHelper コードは次のとおりです。
public string Text { get; set; }
public override void Process(TagHelperContext context, TagHelperOutput output)
{
var builder = new TagBuilder("a");
output.Attributes.Add("data-controller", Controller);
output.Attributes.Add("data-action", Action);
if (!string.IsNullOrEmpty(Text))
{
builder.InnerHtml.Append(Text); // INNER HTML IS HERE!!!
}
builder.AddCssClass("btn btn-link");
output.Content.SetContent(builder);
base.Process(context, output);
}
で、今の使い方はこんな感じです(現状・動作します)
<anchor-box name="ALink" controller="A" action="D" text="© 2016 Murat"></anchor-box>
次のように内部の html テキストを手動で与えることは可能ですか? (必要な状況 - 現在は動作しません)
<anchor-box name="ALink" controller="A" action="D">© 2016 Murat</anchor-box>