I've built a very simple control with a Textbox and an ImageButton. The user types a file number into the Textbox, clicks the image and it submits, taking the user to the appropriate page.
What I'd like to do is capture the Enter keypress event when the textbox has focus, and trigger the ImageButton click event. I've tried using Javascript to do it, but haven't had any luck yet, and don't particularly like hardcoding the rendered names into the control (Wrapper__ctl2_btnQuickSearch, and Wrapper__ctl2_QuickSearchInput).
I'm sure there's a simple way to do this, but so far I haven't had any luck finding it.
Here is the code I'm using so far:
What I'd like to do is capture the Enter keypress event when the textbox has focus, and trigger the ImageButton click event. I've tried using Javascript to do it, but haven't had any luck yet, and don't particularly like hardcoding the rendered names into the control (Wrapper__ctl2_btnQuickSearch, and Wrapper__ctl2_QuickSearchInput).
I'm sure there's a simple way to do this, but so far I haven't had any luck finding it.
Here is the code I'm using so far:
Code:
<script runat="server">
Sub btnQuickSearch_Click(Sender As Object, E As System.Web.UI.ImageClickEventArgs)
Response.Redirect(Application("Root") & "/Member/Opportunity.aspx?ID=" & QuickSearchInput.text)
End Sub
</script>
<asp:panel id="pnlFrame" Runat="Server">
<table class="RecentEdits">
<tr>
<td class="Sidebar-Header">
Quick Search:</td>
</tr>
<tr>
<td class="sidebar-quicksearch">
<asp:TextBox class="sidebar-quicksearch-inputbox" id="QuickSearchInput" runat="server"></asp:TextBox>
<asp:ImageButton id="btnQuickSearch" onclick="btnQuickSearch_Click" runat="server" AlternateText="Quick Search" ImageUrl="../images/details.gif"></asp:ImageButton>
</td>
</tr>
</table>
</asp:panel>