This is a migrated thread and some comments may be shown as answers.

RadAutoComplete does not submit when enter is pressed.

3 Answers 345 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 23 Apr 2013, 04:49 AM
We have the requirement that for a textbox with autocomplete functionality that submits when an asp button is clicked or the user presses enter while the textbox has focus (the use may have entered or selected from the dropdown).

We also need the AllowCustomEntry functionality that RadAutoCompleteBox supplies.

I cannot seem to find a solution in the Telerik tools:
-  RadAutoCompleteBox does not submit on enter. Via JQuery I was able to detect enter and run the click event for my button which submitted to the server ok but the text field for the RadAutoCompleteBox  was blank. When I added a focus event (for the button) before the click event my solution did work in Chrome but not in IE. 

- RadSearchBox. This control does submit on enter but it does not behave like a true text box. That is it does not display the value entered after the selection is made and does not seem to support an ASP button to kick off the search (this is part of the look and feel of our application). It also submits as soon as you select from the drop down which could be confusing for our users.

RADAutoCompleteBox is the closest solution but the fact that it does not post back to the server when enter is pressed is a show stopper for us. Apart from running the JQuery focus event prior to the button click event do you know of any other action I might take.

What I really would like is an autocomplete box that supported a 2 step process: the user selects the entry from the dropdrown which is displayed in the text box and then the user can either press enter or click on the search button to post the text back to the server.

I hope that this is not too much feedback and my questions are clear. Cheers

3 Answers, 1 is accepted

Sort by
0
Dann Vestergaard
Top achievements
Rank 1
answered on 25 Apr 2013, 10:17 AM
Hi Peter,

Any luck on this...?

I am facing the same issue and would like to fire the default button once enter is hit with focus in my textbox.

BR

Dann
0
Bozhidar
Telerik team
answered on 25 Apr 2013, 03:29 PM
Hello,

When you postback the page in your handler, the entries are lost because in Text mode RadAutoCompleteBox uses the blur event to save it's entries into the ClientState (and therefore the server). Therefore you have to trigger blur on the input for the entries to be saved. 

The reason why your logic is not working is related to timing. You have to blur the control and postback after the AutoCompleteBox has had enough time to finish processing the entries. Please try the code patch I've pasted below and see if it works as expected:
var handler = Telerik.Web.UI.RadAutoCompleteBox.prototype._onKeyDown;
Telerik.Web.UI.RadAutoCompleteBox.prototype._onKeyDown = function(e) {
 
    handler.apply(this, [e]); // Let AutoCompleteBox finish it's internal logic
 
    if (e.keyCode == Sys.UI.Key.enter) {
        this._onBlur();
 
        $get("Button1").click();
    }
}

 

Regards,
Bozhidar
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Peter
Top achievements
Rank 1
answered on 28 Apr 2013, 11:57 PM
Thanks very much for this. It does work and allow the textbox to postback on enter.

Cheers Peter
Tags
AutoCompleteBox
Asked by
Peter
Top achievements
Rank 1
Answers by
Dann Vestergaard
Top achievements
Rank 1
Bozhidar
Telerik team
Peter
Top achievements
Rank 1
Share this question
or