Tag Helper's are one of the sweet features of Asp.Net Core. I have created several tag helpers and they can be super helpful.
Now I would like to try something a bit more advanced. Tag helper attributes have the ability to be created in such as way that the attribute value is a model property.
And example of this is the following:
//model
public class MyModel{
public int MyField {get;set;} = 10;
}
//in the view
@model MyModel
...
<input asp-for="MyField" />
In the above example the asp-for
tag helper for the input
tag directed references a property from the model. The documentation says that
The asp-for attribute value is a ModelExpression and the right hand side of a lambda expression. Therefore, asp-for="Property1" becomes m => m.Property1 in the generated code which is why you don't need to prefix with Model.
So this is pretty cool, and that same documentation appears to call this an "Expression name".
How do I create such a property in my own custom tag helper?