Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the naming guidelines for ASP.NET controls?

Tags:

People also ask

What are ASP.NET standard controls?

Standard Controls—Enable you to render standard form elements such as buttons, input fields, and labels. We examine these controls in detail in Chapter 2, "Using the Standard Controls." Validation Controls—Enable you to validate form data before you submit the data to the server.

What is naming Convention in Label control?

Every user interface text must be defined by using a label. A new label must be created for each new semantic use per each model. A label should have an uppercase first letter and all the other internal words should begins with lowercase.

What is the purpose of control naming convention?

These control naming conventions may help provide some organization. Visual Studio sets Name properties to defaults for controls, like Label2. Using these conventions it would be something like lblName.

Which all controls in ASP.NET can be used to display text in a page?

The label control is used to display a text or a message to the user on the form. The label control is normally used along with other controls.


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 named. I am talking about our good friends Label, TextBox, Button etc.

We came up with the following three possibilities that we voted on: (Example is a TextBox to enter/display a FirstName)

  1. Add the control type as a postfix to your controls ID: [FirstName_TextBox] or [FirstName_tbx]
  2. Add the control type as a prefix to your controls ID [tbxFirstName]
  3. Set the ID of the control to FirstName and name related fields (like a label for the textbox or a validator) as in option 2 [lblTextBox].

We ended up deciding to use option 2. It's not as verbose as option 1 and I like that it specifies what control it is before the name of the control.

My question is whether Microsoft has released any guidelines for these prefixes and or if you have any comments about our decision.