Click here to Skip to main content
15,901,373 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,
i have a web form in asp.net in this there is a text box control i want to set focus of this control means when we press F2 key then cursor is move on text box


Thanks & Regards
Srishti
Posted

XML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>

    <script language="Javascript">

function MoveFocusOnF2(event) {
    switch (event.keyCode) {
    case 113:
    document.getElementById("TextBox1").focus();
    break;
    default:
    //nothing
    }
}
    </script>
</head>
<body onkeydown="MoveFocusOnF2(event);">
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    </div>
    </form>
</body>
</html>
 
Share this answer
 
Comments
srishti056 21-May-13 4:48am    
Thanks but how to know keyboard all keycode
SQL
Below link got key values for all keys

http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes
 
Share this answer
 
Comments
srishti056 21-May-13 5:05am    
thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900