<asp:ComboBox ID="dropMake" runat="server" Width="100px"
OnSelectedIndexChanged="MakeListIndexChanged"
DropDownStyle="Simple" AutoCompleteMode="SuggestAppend"
CaseSensitive="False" CssClass="UpperCase"
ItemInsertLocation="OrdinalText"
ToolTip="Enter New Make if not Found"
OnItemInserted="InsertNewMake_Selected" TabIndex="3"
UseSubmitBehavior="false"
>
</asp:ComboBox>
I created a button with a OnClick and wrote this javascript to capture the enter key
else if (keyCode == 13) {
if (tempdropMake.item) {
document.getElementById("Button9").click();
}
return false;
}
but it still postback and returns to the default.aspx on the second enter. Nothing happens on the first enter. I just need to capture the first enter. End users use enter a lot.
If you want the button fires the click event once you press Enter, I wonder why you do not manipulate the TabIndex property and set it to 0 in the button. That way, the Enter key will fire that event in the button. The button will be by default the first
in handling the Enter key event.
If the button make a postback when you press enter because the tabIndex = 0; then you got the button works with the Enter key. However, what is written in the click event of the button? Is there any code in the Event Handler for the Click Event of the button?
aussieracer
0 Points
7 Posts
ComboBox and Enter key causes postback and return to default.aspx
Jan 07, 2013 11:44 PM|LINK
I have the follwing combobox
<asp:ComboBox ID="dropMake" runat="server" Width="100px" OnSelectedIndexChanged="MakeListIndexChanged" DropDownStyle="Simple" AutoCompleteMode="SuggestAppend" CaseSensitive="False" CssClass="UpperCase" ItemInsertLocation="OrdinalText" ToolTip="Enter New Make if not Found" OnItemInserted="InsertNewMake_Selected" TabIndex="3" UseSubmitBehavior="false" > </asp:ComboBox>I created a button with a OnClick and wrote this javascript to capture the enter key
else if (keyCode == 13) { if (tempdropMake.item) { document.getElementById("Button9").click(); } return false; }but it still postback and returns to the default.aspx on the second enter. Nothing happens on the first enter. I just need to capture the first enter. End users use enter a lot.
Any HELP would be appreciated.
Ross
otnielpena
Member
210 Points
38 Posts
Re: ComboBox and Enter key causes postback and return to default.aspx
Jan 08, 2013 01:09 AM|LINK
If you want the button fires the click event once you press Enter, I wonder why you do not manipulate the TabIndex property and set it to 0 in the button. That way, the Enter key will fire that event in the button. The button will be by default the first in handling the Enter key event.
aussieracer
0 Points
7 Posts
Re: ComboBox and Enter key causes postback and return to default.aspx
Jan 08, 2013 01:18 AM|LINK
The button is the only TabIndex with a 0; and it still postsback to default.aspx?? Is there another way to catch the first enter??
It works fine until it inserts new text, just to search the list and set the index and move on is fine.
otnielpena
Member
210 Points
38 Posts
Re: ComboBox and Enter key causes postback and return to default.aspx
Jan 08, 2013 09:32 PM|LINK
If the button make a postback when you press enter because the tabIndex = 0; then you got the button works with the Enter key. However, what is written in the click event of the button? Is there any code in the Event Handler for the Click Event of the button?
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: ComboBox and Enter key causes postback and return to default.aspx
Jan 10, 2013 12:54 AM|LINK