enter key in asp.net firing wrong button

梦想的初衷 提交于 2019-12-03 01:33:42

The standard way in ASP.NET to control which submit button is activated when ENTER is pressed is to wrap the controls and buttons in an asp:Panel with the DefaultButton property set to the correct button.

If I'm reading your question properly, you just want one specific button to be activated when ENTER is pressed, so wrap everything on your page in a single asp:Panel.

<asp:Panel id="pnlDefaultButton" runat="server" DefaultButton="btnOK">
    <!-- All controls here including: -->
    <asp:Button id="btnOK" runat="server" Text="OK" />
</asp:Panel>
Fred

No panel is needed. Just use the following:

UseSubmitBehavior="false"
Lenin Edwin

Please use

idTextBoxFA.Attributes.Add("onkeypress", "javascript:var evnt = window.event";
if(evnt.keyCode==13)
{
document.getElementById('" + noEnterButton.ClientID + "').click();
}
else{};");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!