net webpage, it has two search fields with separate submit buttons.
I’d like to allow the user to enter some data into one of the fields and then press the enter key and it submit using the appropriate button. Right now, the enter key submits for the first submit button, but I want this to change if there is data in the second textbox.
How can I do this?
Currently my code is:
<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" />
<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" />
Have a look at the
DefaultButtonproperty. You can wrap each of those label/button pairs in a panel and set the property tobtnEmployeeSearchandbtnCustomerSearch, respectively.http://forums.asp.net/t/985791.aspx