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

FocusControl() does not work

3 Answers 69 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Lucas County Information Services
Top achievements
Rank 1
Lucas County Information Services asked on 27 Aug 2008, 07:16 PM
I have a form containing three (3) RadComboBoxes. When an item is selected from the first combobox the other two are updated and the focus is supposed to be set on the second combobox. The problem is that the focus is not be set to the second combobox after it has been rebound. What is wrong here?

    Protected Sub radCombo1_SelectedIndexChanged(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs) Handles radCombo1.SelectedIndexChanged  
        BindCombo2()  
        If radCombo3.Text.Length = 0 Then  
            BindCombo3()  
        End If  
 
        radAjaxManager.FocusControl(radCombo2.ClientID & "_Text")  
    End Sub 

3 Answers, 1 is accepted

Sort by
0
Missing User
answered on 28 Aug 2008, 01:05 PM
Hello Doug,


Please find attached the sample web application that demonstrates the needed approach

Regards,
Plamen
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Lucas County Information Services
Top achievements
Rank 1
answered on 29 Aug 2008, 12:21 PM
Thanks so much. That resolved the issue.
0
Lucas County Information Services
Top achievements
Rank 1
answered on 29 Aug 2008, 12:21 PM

I also needed to use this where the radComboBox was in a GridView control. After setting the focus to the combobox I needed the text to be highlighted. When searching the forums I found plenty of examples where the combobox was located on a form, but not inside of a grid. The solution was pretty simple though. In the ASP for the combobox, add the OnClientFocus event:

<telerik:RadComboBox ID="radCombo2" runat="server"   
                     MarkFirstMatch="true"   
                     OnClientFocus="radCombo2_OnFocus"  /> 

Then add this function to a script block:

function radCombo2_OnFocus(sender)  
{  
    sender.selectText(0, sender.get_text().length);  
}  
 

I hope this helps somebody else.
Tags
Ajax
Asked by
Lucas County Information Services
Top achievements
Rank 1
Answers by
Missing User
Lucas County Information Services
Top achievements
Rank 1
Share this question
or