
Introduction
This article shows how to support HotKeys in your ASPX pages.
The steps involved
Step 1
Open VS.NET and create a new ASP.NET Web Application project.

Step 2
Add two web forms: aspxMain.aspx and aspxFunction01.aspx.

Step 3
As the following screenshot shows, add a Label
and three Button
s on aspxMain.aspx.

Step 4
Add a Label
and a Button
on aspxFunction01.aspx.

Step 5
Double-click on Button1
of aspxMain.aspx to change the IDE view to the aspxMain.aspx.cs editor and paste the following code in the editor:
Response.Redirect("aspxFunction01.aspx");
Step 6
Edit the code inside aspxMain.aspx, and add the following to the bottom of the editor:
<SCRIPT LANGUAGE="Javascript">
<!--
function Even() {
key = event.keyCode;
switch(key) {
case 33:
var b = document.getElementById("Button1");
b.click();
break;
case 64:
var b = document.getElementById("Button2");
b.click();
break;
case 35:
ver b = document.getElementById("Button3");
b.click();
break;
}
}
document.onkeypress = Even;
-->
</SCRIPT>
Step 7
Double-click on Button1
of aspxFunction01.aspx to switch the IDE view to aspxFunction01.aspx.cs and paste the following:
Response.Redirect("aspxMain.aspx");
Step 8
Edit the code inside aspxFunction01.aspx, and add the following to the bottom of the editor:
<SCRIPT LANGUAGE="Javascript">
<!--
function Even() {
key = event.keyCode;
switch(key) {
case 41:
var b = document.getElementById("Button1");
b.click();
break;
}
}
document.onkeypress = Even;
-->
</SCRIPT>
Step 9
Test to see whether the project meets your needs or not.
Feel free to let me know your feedback.