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

[Solved] Combo Box losing focus

3 Answers 150 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Pawan Kohli
Top achievements
Rank 1
Pawan Kohli asked on 29 Jun 2009, 11:06 PM
Hi everyone,

Here is the scenario I am having an issue with:

I have two Combo boxes on my webpage, combo box A refreshes combo box B after you move off combo box A. In the code behind for combo box A selected index change is  

RadScriptManager1.SetFocus(COMBOBOXB.ClientID +

"_Input");

However this code does not properly set focus back on the control. The list item that is combo box is not given the blue selection.

Please advise.

Thank you in advance.

 

 

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 30 Jun 2009, 07:00 AM
Hi Pawan Kohli,

Please make sure that the second combo (COMBOBOXB) has AllowCustomText="True" (or MarkFirstMatch="True")
This is needed so the control can receive the focus.

Best wishes,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pawan Kohli
Top achievements
Rank 1
answered on 30 Jun 2009, 03:49 PM
Hello Veselin,

Thank you for your response. The control is recieving focus; however the text within the drop down is not selected(meaning the text is not highlighted blue).

Please advise.
0
Veselin Vasilev
Telerik team
answered on 01 Jul 2009, 11:40 AM
Hi Pawan Kohli,

That code will put the cursor to the input area, but will not highlight the text. To highlight the text please use this approach:

protected void c1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) 
    StringBuilder script = new StringBuilder(); 
    script.Append("Sys.Application.add_load(function(){"); 
    script.Append("var combo2 = $find('" + c2.ClientID + "');"); 
    script.Append("combo2.get_inputDomElement().focus();"); 
    script.Append("combo2.selectText(0, combo2.get_text().length - 1); });"); 
     
    RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "selectText", script.ToString(), true); 

I hope this helps.


All the best,
Veselin Vasilev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
ComboBox
Asked by
Pawan Kohli
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Pawan Kohli
Top achievements
Rank 1
Share this question
or