< %@ Page Language="C#" AutoEventWireup="true" % > <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script runat="server"> protected void Page_Load(object sender, EventArgs e) { _lbl1.Text = _txt1.Text; } </script> </head> <body> <form id="form1" runat="server"> <asp:TextBox ID="_txt1" runat="server" /> <asp:Button ID="_btn1" runat="server" Text="Button1"/> <asp:Button ID="_btn2" runat="server" text="Button2"/> <asp:Label ID="_lbl1" runat="server" /> </form> </body> </html>Pressing ENTER on this page should not cause any post at all (I have tested with IE and Firefox only).
<form id="form1" runat="server" defaultbutton="_btn1">You can also have different default buttons on the same page. But for this to work, you will have to put them in different asp:Panel controls. Each panel can have its own default button which submits the form when that panel has the focus and the user presses ENTER. The page below shows this behavior:
< %@ Page Language="C#" AutoEventWireup="true" % > <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> <script runat="server"> protected void ShowText1(object sender, EventArgs e) { _lbl1.Text = _txt1.Text; } protected void ShowText2(object sender, EventArgs e) { _lbl2.Text = _txt2.Text; } </script> </head> <body> <form id="form1" runat="server"> <asp:Panel ID="Panel1" runat="server" DefaultButton="_btn1"> <asp:TextBox ID="_txt1" runat="server" /> <asp:Button ID="_btn1" runat="server" Text="Button1" OnClick="ShowText1" /> <asp:Button ID="_btn2" runat="server" text="Button2" OnClick="ShowText1" /> <asp:Label ID="_lbl1" runat="server" /> </asp:Panel> <hr /> <asp:Panel ID="Panel2" runat="server" DefaultButton="_btn4"> <asp:TextBox ID="_txt2" runat="server" /> <asp:Button ID="_btn3" runat="server" Text="Button3" OnClick="ShowText2" /> <asp:Button ID="_btn4" runat="server" text="Button4" OnClick="ShowText2" /> <asp:Label ID="_lbl2" runat="server" /> </asp:Panel> </form> </body> </html>Sorry if I missed the track of the discussion, but I had lots of problems in the past (specially with VS 2003) regarding submits and default buttons, so I thought that this would help in some way.