Greetings!
I have a simple navigation menu consisting of an asp:DropDownList and an asp:Button. Users select an item from the dropdown and click the button to go to the new URL. I'd like to be able to able to support when users hit the ENTER key when a dropdown list item is selected so that it replicates the behavior as if they've clicked the button.
Here's what I have thus far:
<asp:DropDownList ID="ddlMenu"
runat="server"
onkeypress="if ((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)) {__doPostBack('GoButton',''); return false;}" />
<asp:Button ID="btnGoButton" runat="server" onclick="GoButton_Click"/>
The button's click code is:
protected void GoButton_Click(object sender, EventArgs e)
{
string l_url = ddlMenu.SelectedItem.Value;
Response.Redirect(l_url);
}
However, everytime I hit the ENTER key, the page posts back but the button's client event handler doesn't fire. Am I missing something?