执行按钮点击事件,当用户preSS在文本框中输入键 [英] Perform Button click event when user press Enter key in Textbox
本文介绍了执行按钮点击事件,当用户preSS在文本框中输入键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Send" />
</ContentTemplate>
</asp:UpdatePanel>
我不得不执行 Button1的
单击事件,当用户preSS 输入
> Textbox1的
I have to perform Button1
click event when user press Enter key
in Textbox1
推荐答案
在aspx页面加载事件
On aspx page load event
this.TextBox1.Attributes.Add("onkeypress", "button_click(this,'" + this.Button1.ClientID + "')");
JavaScript的code
javascript code
<script>
function button_click(objTextBox,objBtnID)
{
if(window.event.keyCode==13)
{
document.getElementById(objBtnID).focus();
document.getElementById(objBtnID).click();
}
}
</script>
这篇关于执行按钮点击事件,当用户preSS在文本框中输入键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文