Friday, July 24, 2009

In javascript find control id in composite databound control

To find the exact id of control that is placed in itemtemplate of composite databound control like (datalist or gridview).Suppose we want control's id onClient click, Call a javascipt function onclientClick and pass a parameter named "event". it is default keyword.
Syntax:

OnClientClick="AddOccupant(event);return false;"
Now go in your javascript function. as in example we go in AddOccupant function in javascript.
Syntax(javascript):

function AddOccupant(event) {
var obj = event.srcElement event.target;
var seltreeNode = obj;
var selectedId = seltreeNode.id;
//now seletedID contains your client side of control that is in compositedatabound control.
}

No comments:

Post a Comment