我想使用 ActionLink 而不是纯 html 来弹出我的模式窗口,但它可以在纯 html 标签上正常工作,但不能在 MVC actionlink 上正常工作,请看下面。
来自:(工作中)
<button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">
至:(错误)
@Html.ActionLink("Edit", "Edit", null, new { id = @item.Id }, new { @data-toggle="modal", @data-target="#myModal" })
Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
最佳答案
您需要在属性名称中使用下划线字符或连字符(html 帮助器将正确输出 html)。另请注意,@
字符不是必需的(仅在使用保留字时才需要,例如 class
或 readonly
)
@Html.ActionLink("Edit", "Edit", null, new { id = @item.Id }, new { data_toggle="modal", data_target="#myModal" })
关于asp.net-mvc - MVC ActionLink html 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31197956/