gpt4 book ai didi

c# - 使用 data-url html 属性的匿名类型成员声明符无效

转载 作者:太空狗 更新时间:2023-10-29 19:51:54 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com