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);
}
Comments: Verified 0524 of Web Helper
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);
}
Comments: Verified 0524 of Web Helper