We can get a ModelExpression using this property in a TagHelper:
[HtmlAttributeName("asp-for")]
public ModelExpression For { get; set; }
I somehow managed* to have a ViewModel which has a ModelExpression property:
public class TemplateViewModel
{
public ModelExpression For { get; set; }
}
Every time I try to pass it, the Model expression is For from TemplateViewModel, not the real Expression which is stored into For:
@model TemplateViewModel
<input asp-for="@Model.For" class="form-control"/>
Above results in:
<input class="form-control" type="text" id="For" name="For" value="Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression" />
I expected, the input, which is described by the ModelExpression instead of literally a ModelExpression for the ModelExpression.
*since I want to have a Template View for an TagHelper using IHtmlHelper::PartialView(). This example is heavy minimized. My main motivation is to create a single <form-group for="" /> TagHelper, which is generating a Bootstrap Form Group.