C#asp.net中的默认按钮问题 [英] Default button issue in c# asp.net

查看:68
本文介绍了C#asp.net中的默认按钮问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
请参见以下代码.

Hi All,
Please see the following code.

<form id="form1" runat="server" defaultbutton="NextButton" defaultfocus="TextBox1">
    <div>
        <asp:Panel ID="Panel1" runat="server">
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <br />
            <br />
            <br />
            <br />
            <br />
            <br />
            <asp:Button ID="BackButton" runat="server" Text="Back" OnClick="Back_Click" />
            <asp:Button ID="NextButton" runat="server" Text="Next" OnClick="Next_Click" />
        </asp:Panel>
    </div>
    </form>



问题是,将焦点设置为后退"按钮,然后按Enter键将触发下一个"按钮事件.如何避免这种情况?

请帮帮我.

在此先感谢.



The problem is, setting focus to back button and pressing enter key will fire the Next button event. How to avoid this?

Please help me.

Thanks in Advance.

推荐答案

我认为您无法避免这种情况.因为"defaultButton"是处理表单上"enter"键按下事件的控件.您需要使用鼠标来单击相应的按钮(或任何其他控件).
I don''t think you can avoid this. Because "defaultButton" is the one which handles the "enter" key press event on the form. You need to use mouse instead to click appropriate button (or any other control).


^ ]
http://kpumuk.info/asp-net /using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/ [
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.panel.defaultbutton.aspx[^]
http://kpumuk.info/asp-net/using-panel-defaultbutton-property-with-linkbutton-control-in-asp-net/[^]


这篇关于C#asp.net中的默认按钮问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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