For ASP controls - let us say we are using button, is it possible to derive from BUTTON, a derived control and create new property called, say , ReferenceID (type say integer) and use that property.
I would like to have a unique id for the control other than the ID we are having
Hemant KumarPosted Sep 29, 2011, 4:36 AM
Yes, it is possible and the way you are thinking about it will work but keep in mind that you will have to keep track of the values assigned to this property in ViewState. What I mean is this (untested code):
Dorababu MekaPosted Sep 29, 2011, 4:36 AM
public class CustomControl : Button
{
public int ReferenceID
{
get
{
if(ViewState["ReferenceID"]!=null)
return int.Parse(ViewState["ReferenceID"].ToString());
return -1;
}
set
{
ViewState["ReferenceID"]=value;
}
}
}