如果我按键盘上的Enter键,如何为登录按钮编写代码 [英] how to write code for login button if i press the enter button in the key board

查看:135
本文介绍了如果我按键盘上的Enter键,如何为登录按钮编写代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求是,如果我按下键盘的Enter按钮然后触发点击事件,那么如何编写此应用程序的代码

my requirement is if i press the enter button of key board then fire click event so how to write the code for this application

推荐答案

在设计器中,突出显示按钮所在的窗体,然后将AcceptButton属性设置为Login按钮.
这意味着Enter键将自动触发它的Click事件.
In the Designer, highlight the form the button is in, and set the AcceptButton property to the Login button.
This means that the Enter key will automatically fire it''s Click event.


如果您谈论的是ASP.NET,则可以添加"DefaultButton" 属性用于页面.

从ASP.NET 2.0开始,据说已为页面定义了默认按钮".通过简单地将"defaultbutton"属性指定为要触发事件的<asp:Button>的ID,即可完成工作.
可以在form标记的Form级别以及<asp:panel>定义标记的面板级别指定defaultbutton属性.在面板级别指定时,对于面板内部的那些控件,将覆盖表单级别设置

示例示例:
If you are talking of ASP.NET, you can add "DefaultButton" property for the page.

In ASP.NET 2.0 onwards, it''s said to have "Default Button" defined for the page. By simply specifying the "defaultbutton" property to the ID of the <asp:Button>, whose event you want to fire, your job is done.
The defaultbutton property can be specified at the Form level in the form tag as well as at panel level in the <asp:panel> definition tag. The form level setting is overridden when specified at the panel level, for those controls that are inside the panel

Sample example:
<form id="Form1"
    defaultbutton="SubmitButton"
    defaultfocus="TextBox1"
    runat="server">



参考:
ASP.NET DefaultButton属性 [默认"按钮的示例用法 [ ^ ]



Refer:
ASP.NET DefaultButton Property[^]
Sample usage of Default button[^]


这篇关于如果我按键盘上的Enter键,如何为登录按钮编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆