asp.net按钮的快捷键?
我想按Ctrl+Enter的时候触发这个按钮的事件,怎么设置或怎么写?
我想按Ctrl+Enter的时候触发这个按钮的事件,怎么设置或怎么写?
答案:脚本代码function ispost()
{
if(event.ctrlKey && event.keyCode==13)
{
document.getElementById("<%=btnPost.ClientID %>").focus();
document.getElementById("<%=btnPost.ClientID %>").click();
}
}页面代码
<table width="417" border="0" align="left" cellpadding="0" cellspacing="0">
<tr>
<td height="20" colspan="2" align="right"> </td>
</tr>
<tr>
<td width="135" height="30" align="right">用户名:</td>
<td width="282" height="30"><input name="name" type="text" runat="server" onkeydown="submitloginclick() " class="INPUT" id="name" />
<a href=> </tr>
<tr>
<td height="30" align="right">密 码:</td>
<td height="30"><input name="password" type="password" class="INPUT" runat="server" onkeydown="submitloginclick()" id="password" />
<a href=> </tr></table>
<asp:TextBox>也支持onkeydown="submitloginclick()"
<asp:Button ID="btnPost" runat="server" Text="登 录" Height="20px"
onclick="btnPost_Click" Width="58px" />用js来捕获键盘事件。
http://www.javaeye.com/topic/164042
http://blog.csdn.net/chenyijiu/archive/2009/05/17/4195989.aspx
嗯,只能通过JS设置
上一个:ASP.NET做毕业设计
下一个:ASP.NET高手来看看