Naming Conventions of Controls
Control Prefix Example
Label lbl lblSurname
TextBox txt txtSurname
DataGrid dg dgResults
Button btn btnSave
ImageButton ibtn ibtnSave
Hyperlink lnk lnkHomePage
DropDownList ddl ddlCompany
ListBox lst lstCompany
DataList dlst dlstAddress
Repeater rep repSection
Checkbox chk chkMailList
CheckBoxList chk chkAddress
RadioButton rdo rdoSex
RadioButtonList rdo rdoAgeGroup
Image img imgLogo
Panel pan panSection
PlaceHolder plh plhHeader
Calender cal calMyDate
Adrotator adr adrBanner
Table tbl tblResults
[All] Validators val valCreditCardNumber
ValidationSummary vals valsErrors
Use Of Property
Whenever assigning some value to the variable use PROPERTY for that purpose.
For e.g.
String name = TextBox1.Text;
In this case we can use…
Private string mName;
Public string Name
{
get{return mName;}
set{mName=value;}
}
this.Name=TextBox1.Text;
Through this we can ensure proper security. And even we can put some validations in the property.
Interface
Try to always use interface. So that it could be easy to write and understand codes for others… for example. To use code where select statement is used.. try to put that code in block like GetValues();
And the code where insert or update statement or proc is used… try to put that code in block like SetValues();
It would be much easier to look at code then.
Assigning values in SQL Statements
We always use select statement like…
Select * from employees where empname = ‘”TextBox1.Text”’ and password =’”TextBox2.Text”’;
This kind of statement can lead to SQL injection… to avoid such things use parameters
Select * from employees where empname=@empname and password=@password;
And again there in one more flaws in the above statement. Never use * in select statement. Always specify column name.
Select empname, password from employees where empname=@empname and password=@password;
Hey Guys, I think that this will be helpful to u all. Rest as and when I will come to know… then I will post it.
No comments:
Post a Comment