开发者

ASP.NET MVC Template Helpers - How to Get Lower case ID's

开发者 https://www.devze.com 2023-02-04 07:29 出处:网络
When using the template helpers in ASP.NET MVC, e.g. Html.EditorFor(x => x.Property) the rendered Html with have a capitalized ID - matching my property name.

When using the template helpers in ASP.NET MVC, e.g. Html.EditorFor(x => x.Property) the rendered Html with have a capitalized ID - matching my property name.

In order to standardize the ID's of all html elements I want this to be lower case. Rather than specifying the ID manually - which won't get updated if I rename my property, I'd like to establish a convention.

I'm sure I read this was possible somewhere and I'm currently scanning the interwebz to find it. But if anyone can help m开发者_StackOverflow社区e and save me time, that would be awesome.


Currently ASP.NET MVC doesn't offer any extension points allowing you to do this.


You could extend the Html.EditorFor; this tutorial can get you started.

Or you use this:

Html.EditorFor(x => x.Property).ToString().ToLower()
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号