-
JS and focus with .Net?
I have two text fields. When I have entered a value in the first textbox activate some code and then the focus should be moved to the next textbox. But the focus stays in the first textbox, what's wrong?
Code:
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="js.aspx.vb" Inherits="Prisberegning2004.js"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<script language="vb" runat="server">
Protected Sub txtTest_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Response.Write("Text was changed to: <b>")
Response.Write(txtTest.Text)
Response.Write("</b><br/>")
End Sub
</script>
<script language="javascript">
if (document.getElementById("txtTest") != null){
document.getElementById("textbox1").focus();
}
</script>
<body>
<form runat="server" ID="Form1">
<p>Enter some text and then tab away from the field to fire the event.</p>
<asp:TextBox ID="txtTest" Runat="server" AutoPostBack="True" />
<asp:TextBox ID="Textbox1" Runat="server" AutoPostBack="True" />
</form>
</body>
</HTML>