Site Search:
Sign in | Join | Help
4Penny.net

ASP.NET

Notes, Tricks and Tips on ASP.NET Coding

August 2007 - Posts

  • How to Create a Default 'Enter' Button

    How to Create a Default 'Enter' Button

    ASP.NET 2.0 introduces the concept of a "default button". New defaultbutton attribute can be used with <form> or <asp:panel> control. What button will be "clicked" depends of where acutally cursor is and what button is choosen as a default button for form or a panel.

    Here is sample HTML code that contains one form and one panel control:

      <form defaultbutton="button1" runat="server">
        <asp:textbox id="textbox1" runat="server"/>
        <asp:textbox id="textbox2" runat="server"/>
        <asp:button id="button1" text="Button1" runat="server"/>

        <asp:panel defaultbutton="button2" runat="server">
            <asp:textbox id="textbox3" runat="server"/>
            <asp:button id="button2" runat="server"/>
        </asp:panel>

    </form>