I am trying to specify HTML5 data-atrribute in my asp.net MVC razor code like below
@Html.DropDownListFor(m => m.Industry, OnePassV3.utility.OptionList.GetIndustryListSelectList()
, new { @class="cs-select cs-skin-slide cs-transparent", @data-init-plugin="cs-select" })
but i am getting error as you can see below in the image.
So, how can I make it wok?
You can show data-attribute in Razor C#, by simply changing dashes(-) into underscrore, so your above code will be like this
@Html.DropDownListFor(m => m.Industry, OnePassV3.utility.OptionList.GetIndustryListSelectList()
, new { @class="cs-select cs-skin-slide cs-transparent", @data_init_plugin="cs-select" })
it will work in Razor view and will be rendered as data-init-plugin="cs-select"
.
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly