Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Input > RadInput setfocus on client side
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered RadInput setfocus on client side

Feed from this thread
  • Jeffrey avatar

    Posted on Dec 28, 2010 (permalink)

    Hi there,

    I have used the following script to set focus on a RadTextBox but both scripts are not working. That is the script can't find the control on the page. I have a master page and my form that contains the RadTextBox is in a contentpane.

    Script 1
     function setFocusToRadInput()
           {
               var radInput = window["
    <%= radInput1.ClientID %>"];
               radInput.Focus();
           }

    Script 2
      function setFocusToRadInput()
           {        

           var radInput = $find("<%=txtApplicationName.ClientID %>");//this returns a null

     

     

               radInput.Focus();
           }

    ID for my RadTextBox control is txtApplicationName. Any help will be appreciated.

    Thanks
    Jeff

     

  • Radoslav Radoslav avatar

    Posted on Dec 29, 2010 (permalink)

    Hello Jeffrey,

    I am sending you a simple example which demonstrates the desired functionality. Please check it out and let me know what differs in your case.

    Greetings,
    Radoslav
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
    Attached files

  • Jeffrey avatar

    Posted on Dec 29, 2010 (permalink)

    Hi Radoslav,
    Thank you for the response.
    The example you attached seems to work.  However, if I transfer the javascript code to a separate javascript file, will this code still work?
    I usually do not like putting javascript code on a html web page.

    Also, I see that you used the RadCodeBlock control, must this control be used to get the javascript code to work?
    Do I have to use the script below? ( I have the Telerik.Web.U dll reference in my project but I don't seem to get javascript intelligence to work). This script is found within the RadScriptManager in the MasterPage.master.
    ===============================================================================================

    <

     

     

    Scripts>
    <%--Needed for JavaScript IntelliSense in VS2010--%>

     

    <%

     

    --For VS2008 replace RadScriptManager with ScriptManager--%>

     

     

     

    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />

     

     

     

    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />

     

     

     

    <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />

     

     

     

    </Scripts>

     

    ===============================================================================================



    So I am trying to accomplish the following:-

    1) Have the javascript code in a separate javascript file
    2)Reference the javascript file from a master page
    3) Call the javascript functions from web page that exist in a contentPlaceholder.

    Thank you in advance and I look forward to hearing from you soon.

    Jeff

  • Radoslav Radoslav avatar

    Posted on Jan 3, 2011 (permalink)

    Hello Jeffrey,

    RadCodeBlock is used to allow server and client script to work well together with AJAX updates. More information you could find in this documentation topic:
    http://www.telerik.com/help/aspnet-ajax/ajxradscriptblockradcodeblock.html
    Also the <% %> block only work in the aspx page itself, not in external files. More information you could find in this links:
    http://forums.asp.net/p/1499630/3544803.aspx
    http://stackoverflow.com/questions/1461930/asp-net-server-side-comments-inside-script-block
    http://stackoverflow.com/questions/1763899/asp-net-script-in-external-js-file
    http://efreedom.com/Question/1-1763899/AspNet-Script-External-Js-File

    Best wishes,
    Radoslav
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.

  • Jeffrey avatar

    Posted on Jan 3, 2011 (permalink)

    Hi Radoslav

    Thank you. I appreciate  your response.

    Jeff.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Input > RadInput setfocus on client side