Click here to Skip to main content
15,920,896 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Hi All,
Please see the following code.
XML
<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>


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.
Posted
Updated 8-Jun-11 23:31pm
v3
Comments
Sergey Alexandrovich Kryukov 9-Jun-11 3:41am    
By the way, pretty bad code. Multiple br... You don't know how to use styles or what?
--SA
Sandeep Mewara 9-Jun-11 5:05am    
Not clear setting focus to back button and pressing enter key will fire the Next button event.
Elaborate. You have set a default focus somewhere else and the default button (pressing enter) would trigger other button.

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).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900