1

picture

Ok so I would like to be able to be in the part number textbox press enter and it do a 'Quick Search'. However when press enter it activates the 'Search' Button instead. The 'Search' Button as the diagram shows is a default button of the panel it is in. But the 'Quick Search' is not in that same panel so I am kinda stumped on how to change this action so it calls click on the button on the 'Quick Search' and not the 'Search'. If this doesn't make since ask more questions and I will update the diagram and question.

Thanks in advance!

New Facts

  • In the browser Render ... these are in the same form
  • I want the Quick Search Button to be a client side button which makes it hard to use a panel and a default button
Micah Armantrout
  • 6,781
  • 4
  • 40
  • 66

2 Answers2

2

Try to place Part Number textbox and Quick Search button in separate Panel with DefaultButton="bnQuickSearck" attribute like follows:

    <asp:Panel runat="server" DefaultButton="bnQuickSearck">
        <asp:TextBox ID="tbPartNumber" runat="server"></asp:TextBox>
        <asp:Button ID="bnQuickSearck" runat="server" Text="Quick Search" />
    </asp:Panel>

EDIT If you have client-based button you can use the following code on javascript:

<div id="divId">
    <input id="txtId" type="text" />
    <input id="btnId" type="button" value="Quick Search" onclick="alert('test')"; />
</div>

<script>
    $("#divId").bind("keypress", function (e) {
        if (e.keyCode == 13) {
            $("#btnId").click();
            return false;
        }
    });
</script>

Make sure jQuery installed in your web application in this case.

Pavel Timoshenko
  • 721
  • 6
  • 13
1

It sounds like you have one big form. If this is the case, when you hit enter in the Part Number field it activates the default action, in this case it would seem to be the "Search" button. If you can break up your forms, they'll each have their own default actions. This will eliminate any need for crazy redirects, AJAX, server-side foo, etc.

dharga
  • 2,187
  • 3
  • 24
  • 33