We can get ModelExpression
using this property in TagHelper:
[HtmlAttributeName("asp-for")]
public ModelExpression For { get; set; }
I somehow managed * with ViewModel, which has a property ModelExpression
:
public class TemplateViewModel
{
public ModelExpression For { get; set; }
}
Every time I try to pass it, the Model expression is For
from TemplateViewModel
, and not the real expression, which is stored in For
:
@model TemplateViewModel
<input asp-for="@Model.For" class="form-control"/>
The above results:
<input class="form-control" type="text" id="For" name="For" value="Microsoft.AspNetCore.Mvc.ViewFeatures.ModelExpression" />
I expected the input that is being described ModelExpression
instead of literaly a ModelExpression
for ModelExpression
.
*, since I want to have a template view for TagHelper using IHtmlHelper::PartialView()
. This example is greatly minimized. My main motivation is to create a single <form-group for="" />
TagHelper that the Bootstrap Forms Group generates .