Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Commented Issue: Custom htmlAttributes rendered incorrectly by WebGrid [575]

$
0
0
data_xxx attributes should be rendered as data-xxx, like other MVC Html helpers. See this StackOverflow question - http://stackoverflow.com/questions/12900138/add-custom-attributes-to-table-rendered-by-webgrid
I also raised this on Connect before realizing MVC is on CodePlex
Comments: The bug is in System.Web.WebPages.TypeHelper.ObjectToDictionary, which is used by WebGrid to convert the anonymous htmlAttributes object to a dictionary: internal static IDictionary<string, object> ObjectToDictionary(object value) { return new RouteValueDictionary(value); } It should be converting underscores to hyphens, as does the helper method System.Web.Mvc.HtmlHelper.AnonymousObjectToHtmlAttributes used by other MVC helpers: public static RouteValueDictionary AnonymousObjectToHtmlAttributes(object htmlAttributes) { RouteValueDictionary dictionary = new RouteValueDictionary(); if (htmlAttributes != null) { foreach (PropertyDescriptor descriptor in TypeDescriptor.GetProperties(htmlAttributes)) { dictionary.Add(descriptor.Name.Replace('_', '-'), descriptor.GetValue(htmlAttributes)); } } return dictionary; }

Viewing all articles
Browse latest Browse all 7215

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>