Creates TIP explaining usage of HtmlAttributeName in custom Tag Helper (#26962)
* Adds note explaining HtmlAttributeName usage * changes HtmlAttributeName hint to TIP * Fixes TIP syntax * removes link to HtmlAttributeName API docs * Updates * Update aspnetcore/mvc/views/tag-helpers/authoring.md * restores f4949b6, moves down and removes TIP markup Co-authored-by: Luke Latham <1622880+guardrex@users.noreply.github.com> Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>pull/26998/head
parent
39a6ff8b1c
commit
86bbca8f9e
|
@ -117,6 +117,21 @@ That approach works for the attribute "href" as long as it doesn't currently exi
|
|||
|
||||
With a self-closing email tag helper, the output would be `<a href="mailto:Rick@contoso.com" />`. Self-closing anchor tags are not valid HTML, so you wouldn't want to create one, but you might want to create a tag helper that's self-closing. Tag helpers set the type of the `TagMode` property after reading a tag.
|
||||
|
||||
You can also map a different attribute name to a property using the [`[HtmlAttributeName]` attribute](xref:Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeNameAttribute).
|
||||
|
||||
To map an attribute named `recipient` to the `MailTo` property:
|
||||
|
||||
```csharp
|
||||
[HtmlAttributeName("recipient")]
|
||||
public string? MailTo { get; set; }
|
||||
```
|
||||
|
||||
Tag Helper for the `recipient` attribute:
|
||||
|
||||
```html
|
||||
<email recipient="…"/>
|
||||
```
|
||||
|
||||
### ProcessAsync
|
||||
|
||||
In this section, we'll write an asynchronous email helper.
|
||||
|
|
Loading…
Reference in New Issue