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

Closed Unassigned: ASP.NET MVC - Id, IdFor, and IdForModel Generate Incorrect Ids [1542]

$
0
0
Ported from https://aspnet.codeplex.com/workitem/5888 (5 votes)

When the name contains an indexer, the Id method in Microsoft.Web.Mvc.NameExtensions generates a different Id than the one generated by the input builder.

For example if the current name is A.B[0].C, the input builder generates the id: A_B_0__C while the Id method would generate A_B[0]_C.

In the mean time, I've updated the Id method to do the following:

private static readonly Func<string, string, string> CreateSanitizedId = (Func<string, string, string>)Delegate.CreateDelegate(typeof(Func<string, string, string>), typeof(TagBuilder).GetMethod("CreateSanitizedId", BindingFlags.Static | BindingFlags.NonPublic));

public static MvcHtmlString Id(this HtmlHelper html, string name) {
return MvcHtmlString.Create(CreateSanitizedId(html.ViewData.TemplateInfo.GetFullHtmlFieldName(name), HtmlHelper.IdAttributeDotReplacement));
}
Comments: This was addressed in https://aspnetwebstack.codeplex.com/workitem/544

Viewing all articles
Browse latest Browse all 7215

Trending Articles



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