Defocus ComboBox on Option Selection

5 posts, 0 answers
  1. Levi
    Levi avatar
    134 posts
    Member since:
    Jul 2008

    Posted 22 Apr 2009 Link to this post

    Is there a way to set focus away from a combobox after a user selects an item? I want the ComboBox to lose focus immediately after the user makes a selection.


  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 22 Apr 2009 Link to this post

    Hi Levi,

    Try out the following code snippet for setting the focus away from RadComboBox on selecting an item.

    ASPX:
     
    <telerik:RadComboBox ID="RadComboBox1" runat="server" OnClientSelectedIndexChanged="OnClientSelectedIndexChanged" >  
           <Items>  
                <telerik:RadComboBoxItem Text="Item1"  Value="Item1" runat="server"></telerik:RadComboBoxItem>  
                <telerik:RadComboBoxItem Text="Item2" Value="Item2" runat="server"></telerik:RadComboBoxItem>  
                <telerik:RadComboBoxItem Text="Item3" Value="Item3" runat="server"></telerik:RadComboBoxItem>                        
           </Items>  
    </telerik:RadComboBox> 

    JavaScript:
     
    <script type="text/javascript"
    function  OnClientSelectedIndexChanged(sender, args) 
      var dom = sender.get_inputDomElement(); 
      dom.blur(); 
    </script> 

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Levi
    Levi avatar
    134 posts
    Member since:
    Jul 2008

    Posted 22 Apr 2009 Link to this post

    Thanks for this, although the code does not seem to have any effect. I checked to make sure it was getting called and everything seems as expected. It does not raise an error though. When the code gets called it is as if nothing happened. I tried both IE and Firefox. Any ideas?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Apr 2009 Link to this post

    Hi Levi,

    I tried above code found that it is working fine in Firefox and IE6. The RadComboBox loses focus on selection changing. Could you paste the code which you tried if it is different from the code I tried?

    Thanks,
    Shinu.
  6. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 24 Apr 2009 Link to this post

    Hi Levi,

    could it be that you do a callback / postback with your combobox?
    If so there are different approaches to achieve what you want.

    I couldn't test the function Shinu provided (I'm almost sure it works) - but I do something like this - I set the focus to a different control on the page - which works.

    Regards

    Manfred
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017