Rectangle 27 0

asp.net Passing ClientId of a textbox to use it in a javascript function?


function masterClick(clicked, controlID) {
    var dynCtrl = clicked.id.substring(0, clicked.id.lastIndexOf("_") + 1);
    var tBox = document.getElementById(dynCtrl + controlID);
    tBox.value = "";
    tBox.focus();
}
masterClick(this,'txt_rol');

change tBox.value and focus to whatever action you like, but should have access to the control in JavaScript now. You can add in a check like " if (tBox) " to ensure you have an object. The downside is the static reference to the control within the inline javascript, and you have to adjust when the calling control is in a different container, grid, panel, etc.

this isn't exactly what i was looking for, but it helped.

Note