We are in the process of nutting out the design guidelines we would like to use in our development team and got into a discussion today around how ASP.NET controls should be
I tend to go with the control type as a prefix and the name of the control afterwards but I always CamelCase so in your example for different types of controls you might have..
For intellisense reasons I also always fully qualify the name of the control so I wouldn't do any of the following...
But ultimately down to personal preference
I use uxCity so that you know it's definitely the User Interface control and not some other object but you don't need to change it if you go from a TextBox to a DropDownList.
However If I had a DropdownList and a Textbox, I'd need to use dlCity and txtCity Or I'd use a combo cboCity.
Hungarian notation was de rigeur when you were limited to 8-character names and no intellisense or debug highlighting. It was a discipline and you could see that if the coding style was correct, the code was likely to be correct. It was used on variables too so you could read the code and understand it as it was a DIY type enforcement.
However, I do use CityTextbox, CityTextboxLabel CityUx, CityUxLbl
It all depends on who is setting the standards on the project.
Not sure about Microsoft official standards, but this is what i've done through out my development career.
I generally abbreviate the control type in front of the the name of what the control does. I keep the abbreviation lower case and the control's name CamelCase.
E.g. A texbox for username becomes tbUserName
Here is a list of standard abbreviations I use:
Abbr - Control
btn - Button
cb - CheckBox
cbl - CheckBoxList
dd - DropDownList
gv - GridView
hl - Hyperlink
img - Image
ib - ImageButton
lbl - Label
lbtn - LinkButton
lb - ListBox
lit - Literal
pnl - Panel
ph - PlaceHolder
rb - RadioButton
rbl - RadioButtonList
txt - Textbox
I found the only reason to use Hungarian notation was that the IDE did not have intellisense and it was not easy to figure out what was what so iCounter was an integer
However the time of using brief to develop is long gone and the IDE shows you the info in a second
Then you inherit VB.NET code and it is not case sensitive so what do you do?
lblFirstName, txtFirstName One is a label the other is the textbox
So how do you name these without case sensitivity and actually know what they are?
uxFirstName & uxFirstName does not work
the only answer i have found is to use Hungarian notation, yes i threw up in my mouth. Then again its vb.net and it should be case sensitive since .net is and all of the compiles to IL.
these are really just based on your preferences but yes, option 2 as described is less verbose and indicates to you the type of control even before its name is shown.
We also use number 2, however I'm not totally convinced it is a good approach. It is Hungarian notation from the "bad" kind, meaning that the prefixes signal the type (syntax) and not the purpose (semantics). The problem with this is that what starts as a TextBox might later become a DropDown and then a RadioButtonGroup, and you'll have to rename the control each time.