Naming and Capitalisation
| Identifier | Case | Examples | Additional Notes | Detailed Info |
| Class | Pascal | Person, BankVault, SMSMessage, Dept | Class names should be based on "objects" or "real things" and should generally be nouns. | |
| Method | Pascal | GetDetails, UpdateStore | Methods should use verbsor verb phrases. | |
| Parameter | camel | personName, bankCode | ||
| Interface | Pascal with "I" prefix | IDisposable | One of the few times when prefixing is adopted. | |
| Property Associated private member variable | Pascal _camelCase | ForeColor, BackColor _foreColor, _backColor | Use underscore camel casing for the private member variables, but keep the names the same as associated property accessors. | |
| Exception Class | Pascal with "Exception" suffix | WebException, SMSException | ||
| Event | Pascal plus optional "EventHandler" suffix where relevant | btnSubmit_Click, Painting, Click, Clicked, MyEventHandler | VS uses underscores to separate an object from its event. Be careful with tense (pre/past), e.g. a Close event that can be canceled should have a Closing event and a Closed event. MS also recommend adding the "EventHandler" suffix where thought needed. |
Naming Conventions for ASP.NET Controls
| Control Name | Example | Prefix |
| Label | lblName | lbl |
| TextBox | txtName | txt |
| GridView | gvResult | gv |
| Button | btnSave | btn |
| ImageButton | ibtnSave | ibtn |
| Hyperlink | lnkHomePage | lnk |
| DropDownList | ddlCompany | ddl |
| ListBox | lstCompany | lst |
| DataList | dlstAddress | dlst |
| Repeater | repSection | rep |
| Checkbox | chkMailList | chk |
| CheckBoxList | chkAddress | chk |
| RadioButton | rdoSex | rdo |
| RadioButtonList | rdoAgeGroup | rdo |
| Image | imgLogo | img |
| Panel | panSection | pan |
| PlaceHolder | plhHeader | plh |
| Calender | calMyDate | cal |
| Adrotator | adrBanner | adr |
| Table | tblResults | tbl |
| [All]Validators | valCreditCardNumber | val |
| ValidationSummary | valsErrors | vals |
Table - 1: Naming Conventions
| WebForm Controls | Prefix | WebForm Controls | Prefix |
| Button | btn | RadioButton | rad |
CheckBox | chk | RadioButtonList | radl |
CheckBoxList | chkl | TextBox | txt |
DataGrid | dgrd | RequiredFieldValidator | valr |
DataList | dlst | CompareValidator | valc |
DrpDownList | drop | RangeValidator | valg |
Image | img | RegularExpressionValidator | vale |
ImageButton | ibtn | CustomValidator | valx |
Label | lbl | ValidationSummary | vals |
LinkButton | lbtn | Table | tbl |
ListBox | lst | Calendar | cal |
In general, naming ASP.NET controls is made using Camel Case naming convention, where the prefix of the name is the abbreviation of the control type name.
| Abbreviation | ASP.NET Control |
| STANDARD CONTROLS | |
| btn | Button |
| cb | CheckBox |
| cbl | CheckBoxList |
| ddl | DropDownList |
| fu | FileUpload |
| hdn | HiddenField |
| lnk | Hyperlink |
| img | Image |
| ibtn(btn) | ImageButton |
| lbl | Label |
| lbtn(btn) | LinkButton |
| lb | ListBox |
| lit | Literal |
| mv | MultiView |
| pnl | Panel |
| ph | PlaceHolder |
| rb | RadioButton |
| rbl | RadioButtonList |
| tbl | Table |
| txt | TextBox |
| v | View |
| DATA CONTROLS | |
| dtl | DataList |
| dp | DataPager |
| dtv | DetailsView |
| ets | EntityDataSource |
| fv | FormView |
| gv | GridView |
| lds | LinqDataSource |
| lv | ListView |
| ods | ObjectDataSource |
| qe | QueryExtender |
| rpt | Repeater |
| smd | SiteMapDataSource |
| sds | SqlDataSource |
| xds | XmlDataSource |
| VALIDATION CONTROLS | |
| cpv | CompareValidator |
| ctv | CustomValidator |
| rv | RangeValidator |
| rev | RegularExpressionValidator |
| rfv | RequiredFieldValidator |
| vs | ValidationSummary |
| C# type name | Visual Basic type name | JScript type name | Visual C++ type name | Ilasm.exe representation | CLR type name |
|---|---|---|---|---|---|
sbyte | SByte | sByte | char | int8 | SByte |
byte | Byte | byte | unsigned char | unsigned int8 | Byte |
short | Short | short | short | int16 | Int16 |
ushort | UInt16 | ushort | unsigned short | unsigned int16 | UInt16 |
int | Integer | int | int | int32 | Int32 |
uint | UInt32 | uint | unsigned int | unsigned int32 | UInt32 |
long | Long | long | __int64 | int64 | Int64 |
ulong | UInt64 | ulong | unsigned __int64 | unsigned int64 | UInt64 |
float | Single | float | float | float32 | Single |
double | Double | double | double | float64 | Double |
bool | Boolean | boolean | bool | bool | Boolean |
char | Char | char | wchar_t | char | Char |
string | String | string | String | string | String |
object | Object | object | Object | object | Object |
No comments:
Post a Comment