Change Focus for Submit Buttons When Users Presses Enter in AJAX .NET Forms


I have an AJAX ASP.NET form that uses a masterpage and C# on the code-behind.

My problem is, that one of the first elements on the page is an ImageButton that is in the masterpage.  I have many different areas of the page that consist of one or two text boxes, that are associated (or intended to be associated) with a submit button.  When a user fills out the required information for any one of these areas (by filling out the one or two text boxes) and presses the enter key, the first ImageButton is fired, instead of the submit button that is associated with the one or two textboxes.  The user expects the submit button associated with the  one or two textboxes to be fired/clicked instead (since the user was working in that area of the page).

Is there anyway that I can ensure that when a user is working in one of these areas of the page (i.e. they've filled out a couple of these textboxes) that the associated (or intended) submit button's click event is fired?

Thank You!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

according to this link you can wrap each collection of controls in an asp:panel and use the DefaultButton property

another tutorial on it

<asp:Panel runat="server" DefaultButton="btnEmployeeSeach">
    <label for="ctl00_cpMain_txtEmployeeSearch">Employee Name:</label><asp:TextBox id="txtEmployeeSearch" runat="server" CssClass="TextBox" />
    <asp:Button ID="btnEmployeeSeach" runat="server" Text="Search" onclick="btnEmployeeSeach_Click" CssClass="button" />
<asp:Panel runat="server" DefaultButton="btnCustomerSeach">
    <label for="ctl00_cpMain_txtCustomerSearch">Customer Name:</label><asp:TextBox id="txtCustomerSearch" runat="server" CssClass="TextBox" />
    <asp:Button ID="btnCustomerSeach" runat="server" Text="Search" onclick="btnCustomerSeach_Click" CssClass="button" />

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suchandsuchAuthor Commented:
Thank you GuitarRich, that was EXACTLY what I was hoping for.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.