Thursday, February 19, 2009

Server Contrl's ID Property !!



Que : What is the ID of ASP.NET server controls ? And why it is used ?

Ans : By ID property of the server control, we can uniquely identify the control.We can not have the two server contros on the same wev forms with same ID. The ID of server control is used as a reference in the c# source code behind file .cs file.
For your control's ID name use some meaning full nameing covention so that your code become more readable and easier to understand.It is very difficult to debug and maintain a program where the control names are TextBox1, Button1, and so forth.
So there are some prefixes appended with meaningful name for server control.
txt = TextBox (e.g. txtLastname)btn = Button (e.g. btnSavedata)ddl = DropDownList (e.g. ddlAccounts)chk = CheckBox (e.g. chkAdmin)rb = RadioButton (e.g. rbSpringsemester)


No comments: