简体   繁体   English

ASP.NET MVC模板助手 - 如何获取小写ID

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

When using the template helpers in ASP.NET MVC, eg Html.EditorFor(x => x.Property) the rendered Html with have a capitalized ID - matching my property name. 在ASP.NET MVC中使用模板助手时,例如Html.EditorFor(x => x.Property) ,呈现的Html具有大写ID - 匹配我的属性名称。

In order to standardize the ID's of all html elements I want this to be lower case. 为了标准化所有html元素的ID,我希望这是小写的。 Rather than specifying the ID manually - which won't get updated if I rename my property, I'd like to establish a convention. 而不是手动指定ID - 如果我重命名我的属性将不会更新,我想建立一个约定。

I'm sure I read this was possible somewhere and I'm currently scanning the interwebz to find it. 我确定我读到这可能在某个地方,我正在扫描interwebz找到它。 But if anyone can help me and save me time, that would be awesome. 但如果有人能帮助我并节省我的时间,那就太棒了。

You could extend the Html.EditorFor ; 你可以扩展Html.EditorFor ; this tutorial can get you started. 教程可以帮助您入门。

Or you use this: 或者你用这个:

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

目前,ASP.NET MVC不提供允许您执行此操作的任何扩展点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM