These two lines:
document.getElementById(textboxId).value = strUser; document.getElementById(textboxId).focus();
also erroneous. If your previous line really worked:
var textboxId = document.getElementById("txtCountry");
what you called textboxId will actually be a text box control, so you will use getElementById using the control instead of a string identifier.
To keep track of what @anthares said; try the following:
var textboxId = '<%=txtCountry.ClientID%>'; alert('My textbox id is: ' + textboxId);
and make sure you get the correct identifier for the text field (remember that it will be launched by ASP.Net, at least make sure that you are not getting anything). Then, when you execute document.getElementById , you need to check the result before using:
var myTextBox = document.getElementById(textboxId); if (myTextBox !== null) { ...now i can access the properties... }
source share