Reputation: 15498
The way an attribute is set on an asp.net core tag helper is as follows:
[HtmlTargetElement("test1",Attributes = "make",ParentTag = "myparent")]
I'm not understanding the syntax Attributes = "make"
I know Attributes is a string that gets passed into the constructor of HtmlTargetElement
but what I don't get is the = "make"
part. If this were the call list of the method I now that would mean make is the value if null is passed in but I don't understand it when it's on the call method side.
What is the Attributes property used for in a HtmlTargetElement
attribute?
Upvotes: 3
Views: 2244
Reputation: 762
The HtmlTargetElement
attribute is used to specify additional criteria for a TagHelper to use when determining a match. The Attributes property specifies that an html element must contain that value to match. The attribute:
[HtmlTargetElement("test1",Attributes = "make")]``
Would match the following element:
<test1 make></test1>
Also keep in mind that you can decorate a class with multiple [HtmlTargetElement]
attributes to result in a logical-OR.
For more examples see this
For official documentation of HtmlTargetElement.Attributes
see here
Upvotes: 5