TagBuilder.MergeAttributes does not work

Dypotaenerrap

New Member
I am trying to make a HtmlHelper and i need to allow user to add it's own custom attributes to the html tag.I tryied to do this using TagBuilder class, but it seems that instead of merging the attributes, it just replaces them.This is what i did in C#\[code\]public static MvcHtmlString List(this HtmlHelperhelper, object htmlAttributes){ var attributes = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes); var tag = new TagBuilder("div"); tag.AddCssClass("myClass"); tag.MergeAttributes(attributes, false); // tag class property has value "myClass", not "myClass testClass" return new MvcHtmlString("<div>");}\[/code\]This is my view:\[code\]@Html.List(new { @class = "testClass" })\[/code\]What am i doing wrong?
 
Back
Top