Invalid member declarator of anonymous type using data-url html attribute

I am doing a small project using jQuery, MVC4 with Razon and C #. In my opinion, I have a drop-down list and I want to give it the attribute 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 this, I get the following 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?

+6
source share
1 answer

data-url not a valid C # identifier.

Use data_url .
MVC will replace _ with - .

+21
source

Source: https://habr.com/ru/post/978166/


All Articles