6 Answers, 1 is accepted
Thank you for reporting this. We will look into the taghelpers implementation, to see where the difference lies.
An important note to make here is that this only applies to the generated id. The name attribute is generated the same, and it's the property used in Model binding. So even though the id's are different, both versions work the same.
Could you share if this manifests in some error on your end, or is it simply an observation of the difference?
As a workaround until the issue is fixed, you can use the $("#Submodel\\.Name") selector.
Any update on this? It's been two years and I just had the pleasure of troubleshooting a problem that was not mine.
Here's some sample code to reproduce the issue from my testing:
Setting the Name is also what assigns the ID. With the HTML Helpers above, both result in names containing periods and ID's containing underscores (as they should). With the Tag Helpers, on the other hand, both the names and IDs contain periods (which results in an invalid HTML id per the specs).
Looking at some of the code, it looks like the problem might be in TagHelperBase.cs's GenerateId() method. This is calling GetFullHtmlFieldName() to retrieve the name, then it directly assigns Id to the same value (without sanitizing it by calling something like GenerateIdFromName).
Could you please test the behavior with the latest UI for ASP.NET Core version? Below you will find a link to the bug issue in our official GitHub repo. As you could see, the bug fix was released with the 2020 R3 release (2020.3.915 version).
Starting with the mentioned version the id with both TagHelpers and HtmlHelpers should be rendered with a lower dash.
I have tested the provided snippet in a sample Ui for ASP.NET Core application. You could see the rendered elements in the screencast here. I also added a standard Html Textbox helper, just as a comparison. With the latest UI for the ASP.NET Core version, the behavior of the standard Html helpers, the Kendo Html Helpers, and tag helpers is consistent, and the id will be rendered with a lower dash.
I hope the provided information will be helpful.
Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.