Html select标签在.net core 版本中调用后台代码出现的问题:
标记助手“option”在元素的属性声明区域中不得包含C#
The tag helper 'option' must not have C# in the element's attribute declaration area

写法会出现错误提示:
RZ1031: The tag helper 'option' must not have C# in the element's attribute declaration area.
RZ1031:标签帮助器“选项”在元素的属性声明区域中不能有c#。
编辑器认为,@(“...”) 不是一个属性。
解决办法是在每个使用了@(“...”)的option前加上"!"
<!option value="@item.Key" @(item.Key==Model.FormType?"selected":"")>@item.Value</!option>

遇到如上问题可以使用!禁用标签助手即可解决。
博客主要讲述了在.net core版本中,Html select标签调用后台代码时出现的问题,即标记助手‘option’在元素属性声明区域不能有C#,编辑器认为@(‘...’)不是属性。解决办法是在使用了@(‘...’)的option前加‘!’禁用标签助手。
623

被折叠的 条评论
为什么被折叠?



