Home  »  Code Snippets  »  ASP.Net  »

How to change focus using enter in asp.net

 Posted By : Manoranjan SahooPosted Date : 11/11/2010 05:15:22 PM Category : ASP.Net Points : 3

Sometimes we need to change focus from one control to another control in asp.net page and we have all server control. To achieve that check below code :

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server" onkeypress="if(event.keyCode=='13')document.form1.TextBox2.focus();"></asp:TextBox>
        <asp:TextBox ID="TextBox2" runat="server" onkeypress="if(event.keyCode=='13')document.form1.TextBox3.focus();"></asp:TextBox>
        <asp:TextBox ID="TextBox3" runat="server" onkeypress="if(event.keyCode=='13')document.form1.TextBox1.focus();"></asp:TextBox>
    </div>
    </form>
</body>
</html>

Thank You.

Responses
No responses found for this thread. Be the first to respond this thread.
Post Reply
Login to post Response.