Reputation: 1277
if i make a select & option tags, then visual studio will render it purple, marking it a taghelper.
But then i cant put in custom attributes with code like this:
Its red, but the @ should be yellow, and the foo should be normally black.
When i run it, the first option should have the attribute called data-foo, but it doesn't exist.
But when put code inside a script tag that is drawed purple, then it works, like this:
Here, it has the normal color, and when i run it and look in developer tools, i can see the data-foo attribute in the dom.
However, if i put the @foo code at the end, then it doesn't work, similar to option, like this:
So, is this a bug or what is going on?
I also tried to put to @foo at the beginning of the option tag, but it still draws it red.
Upvotes: 2
Views: 129
Reputation: 33851
I don't believe it's currently possible to use @ syntax to specify an attribute name in a tag helper. However, you can use @ syntax to specify an attribute value like so:
@{
string fooValue = "someValue";
}
<select>
<option value="red" data-foo="@fooValue">Red</option>
<option value="green">Green</option>
</select>
and it color codes accordingly:
Upvotes: 1