I am trying to add the onkeydown attribute to an asp:textbox. For some reason my code can't find the textbox that is inside a loginview.
Am I doing something wrong?
<script type="text/javascript">
window.onload = function() {
UserName.Attributes.Add("onKeyDown", "KeyDownHandler('" + btn.ClientID + "')");
Password.Attributes.Add("onKeyDown", "KeyDownHandler('" + btn.ClientID + "')");
}
function KeyDownHandler(btn)
{
if (event.keyCode == 13)
{
event.returnValue=false;
event.cancel = true;
document.getElementById(btn).click();
}
}
</script>