2

Closed

Custom attributes - underscores in name should be replaced

description

When passing custom attributes to helpers via anonymous object, the "_" should be replaced with "-" just like in MVC helpers

example:
    [Fact]
    public void WebGridCustomHtmlAttributeIsSpecified()
    {
        var grid = new WebGrid(GetContext(), ajaxUpdateContainerId: "grid")
            .Bind(new[]
            {
                new { P1 = 1, P2 = '2', P3 = "3" },
                new { P1 = 4, P2 = '5', P3 = "6" }
            });
        var html = grid.GetHtml(htmlAttributes: new {data_attribute = "value"});
        string _html = html.ToHtmlString();
        Assert.Contains("data-attribute", _html);
    }
Closed May 24, 2013 at 10:15 PM by yjhong
Verified 0524 of Web Helper

comments

eilonlipton wrote Apr 16, 2013 at 12:20 AM

There's a common helper used in most of MVC and Web Pages that converts from a type to a dictionary and doing the underscore conversions. We probably need to change WebGrid from using RouteValueDictionary to use that helper.

kenegozi wrote Apr 16, 2013 at 11:13 PM

Happens across HtmlHelper in WebPages.
Work item title updated to reflect.
fix in code review