How to create a Default "Enter" Button for Forms/PostBacks

The following does not work and is here only for historical reasons.

You have probably read Scott Hanselman's article on How to create a Default "Enter" Button for Forms/PostBacks. I just wanted to do a little update as the Page.RegisterHiddenField method is now obsolete. If you try the above, Visual Studio will helpfully remind you of the fact and suggest that you use ClientScript.RegisterHiddenField(string, string) instead. So here it is: 
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            UseEnterKeyForGenerateDrawings();
        }

        private void UseEnterKey()
        {
            ClientScript.RegisterHiddenField("__EVENTTARGET", "btnSearch");
        }
    }
You will want to replace btnSearch with the ID of the button you have in your form. In the following example, you would use "btnBuy" in place of "btnSearch".
<asp:button id="btnBuy" onclick="btnBuy_Click" runat="server" text="Search"></asp:button>
So your method looks like
        private void UseEnterKey()
        {
            ClientScript.RegisterHiddenField("__EVENTTARGET", "btnBuy");
        }
I hope this helps. Until next time, bye!