Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access

后端 未结 4 2168
青春惊慌失措
青春惊慌失措 2021-01-01 11:26

I\'m trying to add additional attribute data-icon to my Action Link, but I\'m getting the error below:

Invalid anonymous type member

4条回答
  •  失恋的感觉
    2021-01-01 11:44

    Use "data_icon" instead of "data-icon".

            @Html.ActionLink("Profile", "Details", "Profile", new { id = 11 }, 
            new { @rel = "external", @id = "btnProfile", @data_icon = "gear" })
    

    The _ will automatically be converted to - in the resulting markup.

提交回复
热议问题