window.addEventListener("keydown", checkKeyPressed, false); function checkKeyPressed(e) { alert(e.keyCode); if (e.keyCode == "65") { alert("The 'a' key is pressed."); } }
不過GridView分頁要用鍵盤數字鍵去做分頁選擇的話
比較簡單的做法,直接放一個TextBox和一個Button
後端Page_Load裡面一個 TextBox1.Focus();
前端
<div style="position: absolute; top: -1500px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button2" runat="server" Text="Button" OnClick="Button2_Click" />
</div>
後端
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
TextBox1.Focus();
}
要注意Button2放的位置,如果上一個有Button的話,在TextBox按下ENTER 只會執行第一個Button
沒有留言:
張貼留言