使用data-url html属性的无效的匿名类型成员声明符 [英] Invalid anonymous type member declarator using data-url html attribute

查看:181
本文介绍了使用data-url html属性的无效的匿名类型成员声明符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery,带有Razon和C#的MVC4制作一个小项目.在我看来,我有一个下拉列表,希望将其赋予data-url=Url.Action("UpdateDeliveryAddress", "Home"):

I am making a small project using jQuery, MVC4 with Razon and C#. In my view I have a drop down list and I wish to give it the attribute of data-url=Url.Action("UpdateDeliveryAddress", "Home"):

<div class="@dropDownListClass">
    @Html.DropDownList("theList", null, new {data-url=Url.Action("UpdateDeliveryAddress", "Home") })
</div>

但是,当我这样做时,出现以下错误:

However, when I do so, I get the follow error:

invalid anonymous type member declarator anonymous type members must be declared with a member assignemnt, simple name or member access.

我想念什么?为什么会出现此错误?

What am I missing? Why do I have this error?

推荐答案

data-url不是有效的C#标识符.

data-url is not a valid C# identifier.

相反,请使用data_url.
MVC将_替换为-.

Instead, use data_url.
MVC will replace _ with -.

这篇关于使用data-url html属性的无效的匿名类型成员声明符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆