set focus to textbox in tooltip

6 posts, 0 answers
  1. dhlennon
    dhlennon avatar
    32 posts
    Member since:
    Oct 2006

    Posted 17 Apr 2008 Link to this post

    Could someone be kind enough to give an example of the javascript required to automatically set the focus to a textbox in a tooltip when the tip is displayed please? I can't work this out from the client-side docs (Q12008). thanks
  2. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 21 Apr 2008 Link to this post

    Hello David Lennon,

    I suggest using the RadToolTip's  OnClientShow event to set the focus. You can achieve this by using the following javascript function:


    function OnClientShow(sender, eventArgs)     
          {     
            setTimeout(function()     
              {        
                 var textBox = $get("<%= TextBox1.ClientID %>");        
                 try       
                 {        
                  if(textBox)        
                    textBox.focus();        
                 }        
                 catch(e){};        
              }     
              , 500);        
          }    
     


     <telerik:RadToolTip ID="RadToolTip1" runat="server" TargetControlID="HyperLink1" 
                OnClientShow="OnClientShow">  
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></telerik:RadToolTip> 


    Regards,
    Svetlina
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ozzie
    Ozzie avatar
    3 posts
    Member since:
    May 2009

    Posted 29 May 2009 Link to this post

    yup... worked for me... THANKS
  5. groggi
    groggi avatar
    2 posts
    Member since:
    Sep 2006

    Posted 03 Feb 2010 Link to this post

    Hi there
    I'm using masterpages. where do I have to put the js function code block?
    tx
    sven
  6. groggi
    groggi avatar
    2 posts
    Member since:
    Sep 2006

    Posted 03 Feb 2010 Link to this post

    I found out:

     

    ... (at the end):
    <
    telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

     

     

    <script language="javascript" type="text/javascript">

     

     

    function OnClientShow(sender, eventArgs) {

     

    setTimeout(

    function() {

     

     

    var textBox = $get("<%= paketscheinnummer.ClientID %>");

     

     

    try {

     

     

    if (textBox)

     

    textBox.focus();

    }

     

    catch (e) { };

     

    }

    , 500);

    }

    </

     

    script>

     

    </

     

    telerik:RadScriptBlock>
    </asp:Content>

     

  7. Svetlina Anati
    Admin
    Svetlina Anati avatar
    2795 posts

    Posted 05 Feb 2010 Link to this post

    Hello groggi,

    I am glad to hear that you managed to find solution yourself. The correct place to put the script is in the content page as you have found yourself because you are using code blocks (<%%>) and this is sever code which will throw an exception that the control is not found if it is put in a page which does not contain the control in the code block.

    Best wishes,
    Svetlina
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017