Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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)?

share|improve this question
add comment

4 Answers

up vote 3 down vote accepted

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.

share|improve this answer
add comment

It's the second version, AddressLabel. However,

  1. 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.

  2. I prefer uxAddressLabel and uxAddressTextBox. 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.

share|improve this answer
1  
+1 for the ux comment idea –  Sam Mar 18 '13 at 22:21
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
2  
welcome to programmers. the question is about naming controls. so, your answers is not really addressing the question. the op is aware of the general benefit, otherwise he would not have asked the question in the first place ;-). –  kr1 Mar 26 '13 at 7:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.