While developing web applications we don’t know the id of the control many times (mostly when controls are added dynamically ) .In JavaScript we can get the control and its properties on On Click event of the control.
HTML Code
<button name=’<%# Eval (“ProductName”) %>‘ value=”Open” onclick=”javascript:test();”>Open</button>
Javascript Code
var tag;
tag=“Element name: “ + window.event.srcElement.tagName + ” ID: “ + window.event.srcElement.id;
document.write(tag);
}
</script>