what is the best naming convention for a user control?" e.g. id="LblUserName", id="LabelUserName", or id="UserNameLabel"? [closed]
what is the best way to call my controls?
LblUserName or LabelUserName or UserNameLabel
For naming convention of a web control i usually follow this Convention
The reasoning behind this is that when using Intellisnse, you will be able to see your controls grouped together due to the first letters. So when typing "lbl" you will see all your Label controls, etc...
Its up to you really and what are you used to, just be consistent whit naming. I name my controls like:
lblUsername, txtAddress, btnSave, chbRemeberMe, cmbCategory...
After some time you may not remember how and why you called something the way you did. But you may know that you are looking for textbox or button. Since we read from left to right, i think this way is better, more organised and easier to find controls.
LblUserName is better way to call controls.
General convention is to use lblUserName
or txtUserName
. Note the lowercase first letter.
精彩评论