Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1960
Cancel postback when hitting enter on an item
posted

I have my webcombo configured to ComboTypeAhead = Suggest and EnaleXmlHttp = true.

When the grid is displayed I can click a row with the mouse. The value is displayed in the combo and the grid closes. Now, if I change the selected row using the keyboard arrows and then press enter, there is a postback. Is there a way to cancel that postback?

Thanks.

  • 28464
    Verified Answer
    posted

    Yes, this took me some time to figure out as well. Here is what I got working on my case - the idea is to handle the EditKeyDown event and check the keyCode - if it is 13 (Enter), close the dropdown and the return true to cancel the postback.

        <script language="javascript">
       
        function keyDown(combo, newValue, keyCode)
        {
            if (keyCode == 13)
            {
                var combo = igcmbo_getComboById(combo);
                combo.setDropDown(false);
                return true;           
            }
        }
       
        </script>
       
        <igcmbo:WebCombo ID="WebCombo1" runat="server" DataSourceID="AccessDataSource1">       
            <ClientSideEvents EditKeyDown="keyDown" />

    Hope this helps.