asp.net mvc - Adding data- attribute to an ASP MVC @Html.RouteLink -
i use javascript library hits data- attribute in link have created.
@model ienumerable<string> @foreach (var link in model) { @html.routelink( link, new { controller = "product", action = "list", category = link, page = 1 }, new { @class = link == viewbag.selectedcategory ? "selected" : null, id= link.replace(" ","") } ) }
i able add class , id when try add data-filter returns , error
@class = link == viewbag.selectedcategory ? "selected" : null, data-filter = link.replace(" ","")
invalid annonymous type
@class = link == viewbag.selectedcategory ? "selected" : null, data_filter = link.replace(" ","")
as d.r. has pointed out, mvc has option of turning underscores in dashes.
Comments
Post a Comment