Rather than asp.net, you should handle this client side using javascript or easier with jQuery. Here is an example ...
$(document).keypress(function(e) {
if(e.which == 13) {
alert('You pressed enter!');
}
});
Instead of the alert box, use the jQuery focus method to give the target element focus, or show/hide divs, etc...
JorgeM
Industrious Poster
4,026 posts since Dec 2011
Reputation Points: 297
Solved Threads: 549
Skill Endorsements: 115
So, if you are not familiar with jQuery, you may want to do some reading up on it. Its a very powerful JavaScript library. Very easy to use.
In your example, you may have forgotten to reference the jQuery library. Here is a complete example which you can adapt to your needs.
<%@ Page Language="VB" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Demo</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<form id="form1" runat="server">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button" />
</form>
<script>
$(document).keypress(function (e) {
if (e.which == 13) {
alert('You pressed enter!');
} else {
alert('You did not press enter!');
}
});
</script>
</body>
</html>
JorgeM
Industrious Poster
4,026 posts since Dec 2011
Reputation Points: 297
Solved Threads: 549
Skill Endorsements: 115
The first issue is that you have the script block outside of the closing body tag. Secondly to switch the "enter" key for "tab", you'll need to do some additional reasearch. I havent had time to test this myself, but did a quick search and found a solution online which indicates working, tested code.
JorgeM
Industrious Poster
4,026 posts since Dec 2011
Reputation Points: 297
Solved Threads: 549
Skill Endorsements: 115