本文介绍了按文本框中的Enter键后执行按钮单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! < div 样式 = 身高:80px ; float:right; > < div class = topLogin > < div style = float:right; onkeypress = BtnSearch_Click > < 输入 type = text 占位符 = 关键字或项目编号 id = TxtSearch runat = server / > < 按钮 type = button class = button-bevel orange id = BtnSearch runat = server onserverclick = BtnSearch_Click title = 搜索 > 搜索< / button > <% - < asp:Button ID = Button1 runat = server Text = 搜索 CssClass = button-bevel orange Width = 70px OnClick = BtnSearch_Click /> ; - %> < / div > 解决方案 访问这里.. 当按下输入键时,按钮单击事件在文本框内(在Web中) [ ^ ] 和代码使用这个.. TextBox1.Attributes.Add(onkeydown,if(event.which || event.keyCode){if((event.which == 13)||(event.keyCode == 13)){document.getElementById('ctl00_ContentPlaceHolder1_Button1')。click(); return false;}} else {return true} ; ); 你试过google吗? https://www.google.nl/search?q=asp.net+Execute+按钮+点击+后+按+输入+键+ + +文本框 [ ^ ] 祝你好运! <div style="height: 80px; float: right;"> <div class="topLogin"> <div style="float: right;" onkeypress="BtnSearch_Click"> <input type="text" placeholder="Keywords or Item Number" id="TxtSearch" runat="server" /> <button type="button" class="button-bevel orange" id="BtnSearch" runat="server" onserverclick="BtnSearch_Click" title="Search"> Search</button> <%--<asp:Button ID="Button1" runat="server" Text="Search" CssClass="button-bevel orange" Width="70px" OnClick="BtnSearch_Click" />--%> </div> 解决方案 visit here..Fire Button Click Event when enter key is pressed Inside Textbox(in Web)[^]and Code use this..TextBox1.Attributes.Add("onkeydown", "if(event.which || event.keyCode){if ((event.which == 13) || (event.keyCode == 13)) {document.getElementById('ctl00_ContentPlaceHolder1_Button1').click();return false;}} else {return true}; ");Have you tried google?https://www.google.nl/search?q=asp.net+Execute+button+click+after+pressing+Enter+key+in+textbox[^]Good luck! 这篇关于按文本框中的Enter键后执行按钮单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-30 08:20