Html select标签在.net core 版本中调用后台代码出现的问题:
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>
遇到如上问题可以使用!禁用标签助手即可解决。