I need to pass the client ID of the Javascript function in the onblur event of the ASP.net control event as follows:
OnBlur="javascript:setBackground(this, '<%= txtClientName.ClientID %>')"
Here is my Javascript function:
function setBackground(sender, controlID) { sender.style.backgroundColor = "#ffffff"; var nextElement = document.getElementById(controlID); if ((nextElement.value == '' || nextElement.value == 'Select') && tab == true) { nextElement.style.backgroundColor = "#f7C059" tab = false; } }
The problem is that the client ID is passed literally as "<% = txtClientName.ClientID%>" instead of the actual value. So, calling document.getElementById (controlID); does not work.
How can I get the actual client id and pass it to my Javascript function?
source share