心 涯

NET&JAVA&PHP(要跨界,你不只要跨「脑」的界限,更要跨越「心」的界限,不怕改变,不怕再学习!)

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
1.按回车键不提交数据。 
if (window.event.keyCode == 13)
{
    event.returnValue=false;
    event.cancel = true;
}
2.在文件框中按回车键触发提交事件
TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('"+Button1.UniqueID+"').click();return false;}} else {return true}; ");
3.ASP.NET2.0中网页打开设置一个默认的按钮焦点
<form defaultbutton="button1" runat="server">
    <asp:textbox id="textbox1" runat="server"/>
    <asp:textbox id="textbox2" runat="server"/>
    <asp:button id="button1" text="Button1" runat="server"/>

    <asp:panel defaultbutton="button2" runat="server">
        <asp:textbox id="textbox3" runat="server"/>
        <asp:button id="button2" runat="server"/>
    </asp:panel>

</form>
Trackback:http://www.beansoftware.com/ASP.NET-Tutorials/Accept-Enter-Key.aspx
posted on 2007-11-06 12:06  witer666  阅读(579)  评论(0编辑  收藏  举报