3

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

4 Answers 4

3

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.

6

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.

1
  • 1
    +1 for the ux comment idea
    – Sam
    Mar 18, 2013 at 22:21
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.

0

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
  • 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, 2013 at 7:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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