作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我正在使用 jQuery、MVC4、Razon 和 C# 制作一个小项目。在我看来,我有一个下拉列表,我希望给它 data-url=Url.Action("UpdateDeliveryAddress", "Home")
属性:
<div class="@dropDownListClass">
@Html.DropDownList("theList", null, new {data-url=Url.Action("UpdateDeliveryAddress", "Home") })
</div>
但是,当我这样做时,出现以下错误:
invalid anonymous type member declarator anonymous type members must be declared with a member assignemnt, simple name or member access.
我错过了什么?为什么会出现此错误?
最佳答案
data-url
不是有效的 C# 标识符。
相反,请使用 data_url
。
MVC 会将 _
替换为 -
。
关于c# - 使用 data-url html 属性的匿名类型成员声明符无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26920431/
我是一名优秀的程序员,十分优秀!