I cannot find any naming standards/conventions in MSDN for naming ASP.NET controls.
One of the following standards tends to be used by programmers:
lblAddress
AddressLabel
Address
According to MSDN’s Name of Type Members, should we be treating ASP.NET controls as fields, hence using Pascal Case (e.g. AddressLabel
)?
0
I’m for your second entry, AddressLabel
. For a couple reasons. One, I believe that the Hungarian Notation first one is out of favor in a big way. Next, I believe that a lot of times labels precede input fields or another chunk of text, so there could be several “Address” controls and they’ll need to be disambiguated in some form. Hence, AddressLabel
.
It’s the second version, AddressLabel
. However,
-
If it’s just a label, and you never refer to it in code, you can go with the default
label1
,label2
, or whatever the IDE automatically assigns. -
I prefer
uxAddressLabel
anduxAddressTextBox
. This causes intellisense to group all the controls together, and makes them much easier to refer to. This is my only remaining use for Hungarian notation.
1
Yes controls are fields of your Page class. You should name it with camel casing. Like lblResult, grdEmployees etc. If you do not have any good naming convention in your company then you can use Microsoft naming convention. You can read more about basic Microsoft naming convention here.
In programming language naming convention have great benefits to reduce the effort needed to read and understand source code. It provides better understanding in case of reuse code after a long interval of time. It is an initial step for beginner to learn any programming language. It is a very important element
A good reference regarding this:http://cybarlab.blogspot.com/2013/02/standard-naming-convention-for-aspnet.html
Hope it will help you
Best regard
1