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

asked Mar 18, 2013 at 14:56
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.

answered Mar 18, 2013 at 15:17
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.

answered Mar 18, 2013 at 15:18
0
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.

answered Aug 3, 2013 at 7:00
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

answered Mar 26, 2013 at 6:31
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 ;-). Commented Mar 26, 2013 at 7:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.