Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Invalid anonymous type member declarator using data-url html attribute

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?

like image 443
Flame_Phoenix Avatar asked Nov 13 '14 23:11

Flame_Phoenix


Video Answer


1 Answers

data-url is not a valid C# identifier.

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

like image 135
SLaks Avatar answered Oct 13 '22 00:10

SLaks