为什么HTML id属性在ASP.NET中是大写的? [英] Reason why html id attribute is uppercase generated in ASP.NET?

查看:69
本文介绍了为什么HTML id属性在ASP.NET中是大写的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对ASP.NET还是很陌生.当创建已经包含ASP.NET组件的新页面时,id属性以大写形式生成,对于其他元素,id属性以小写形式生成:

I am quite new to ASP.NET. When creating new pages that already contain ASP.NET components the id attribute is generated in upper case, for other elements the id attribute is generated in lower case:

<asp:xxx ID="foo" ...>
  vs.
<div id="blaa" ...>

我想知道这是什么原因.在这两种情况下,我都倾向于使用小写字母-可以吗?有人可以在这上面加些阴影吗?

I am wondering what the reason for that is. I would tend to use lower case in both cases - is that ok? Can someone please shade some light on this?

非常感谢!

推荐答案

使用< asp:xxx 时,属性名称必须与控件类 xxx .

When you use <asp:xxx the attribute names have to match the properties of control class xxx.

Microsoft的命名约定是2个字母的首字母缩写词为大写,因此属性名称为 ID .

Microsoft naming convention is that 2 letter acronyms are upper case, so the property name is ID.

其他任何超过2个字母的财产名称都将是CamelCase.

Any other property name longer than 2 letters will be CamelCase.

服务器将解析< asp:xxx 标记,因此结果HTML看起来可能非常不同.

The server will parse the <asp:xxx tag, so the result HTML might look very different.

或者,< div 是HTML,并且全部为小写.服务器将按照您在页面中的方式对其进行服务.

Alternatively <div is HTML and will be all lowercase. The server will just serve it up as it is in your page.

这篇关于为什么HTML id属性在ASP.NET中是大写的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆