如何在razor中的@Html.RadioButtonFor中添加aria-label?

2024-05-01

在我使用的 MVC 剃刀视图中@Html.RadioButtonFor。我想使用 aria-label 作为屏幕阅读器,但不知道如何使用它。

如果我添加aria-label然后我得到The name 'aria' does not exist in current context error.

@Html.RadioButtonFor(options => options.SelectedFulfillmentType, option, new { id = id, required = "required", @class = option.GetDisplayName().ToLower().Replace(" ", "-") + "-input", aria-label = "Test"})

如果我添加aria_label然后我没有收到任何错误,但我在浏览器上没有看到该标签。

@Html.RadioButtonFor(options => options.SelectedFulfillmentType, option, new { id = id, required = "required", @class = option.GetDisplayName().ToLower().Replace(" ", "-") + "-input", aria_label = "Test"})

None

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在razor中的@Html.RadioButtonFor中添加aria-label? 的相关文章

随机推荐