Accessing Toolbar client template controls.

6 posts, 0 answers
  1. Craig
    Craig avatar
    14 posts
    Member since:
    Sep 2008

    Posted 10 Dec 2008 Link to this post

    I'm not understanding whey this is not returning the text box control client side. The asp textbox is always Null. I just want to set the textbox to have focus when the page loads.

     

    <telerik:RadToolBar ID="ProductFindViewRadToolBar" OnButtonClick="ProductFindRadToolBar_ButtonClick" OnClientLoad="FocusFindTextBox" Runat="server" CausesValidation="false" >

     

    <Items 

     

    <telerik:RadToolBarButton id="ProductFindViewRadToolBarTextBoxButton" CausesValidation="false" Value="TextBox">

     

    <ItemTemplate>

     

    <div style="padding:0 0 0 5px">

     

    <asp:TextBox ID="ProductFindTextBox" Width="250px" onkeydown="OnEnterKeyDown()" runat="server" />

     

    <asp:Label ID="WarningLabel" CssClass="GenericAlertMessage" runat="server" Text="" Width="0" /></div>

     

    </ItemTemplate>

     

    </telerik:RadToolBarButton>

     

    <telerik:RadToolBarButton Text="Find Now" ToolTip="Find Now" id="ProductFindViewRadToolBarFindButton"></telerik:RadToolBarButton>

     

    </Items>

     

    </telerik:RadToolBar>

     

    function FocusFindTextBox() {

     

    var toolBar = $find("<%= ProductFindViewRadToolBar.ClientID %>");  //Good Object

     

    var button = toolBar.findItemByValue("TextBox") //Good Object

     

    var textBox = button.findControl("ProductFindTextBox"); //NULL EVERY TIME

    alert(textBox);

    }

     

     

  2. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 11 Dec 2008 Link to this post

    Hello Craig,

    The findControl client-side method finds only ASP.NET Ajax client-side controls (other RadControls for example). To find a generic HTML element you can use the findElement method:


    var textBox = $telerik.findElement(button.get_element(), ("ProductFindTextBox"));

    In the future we would implement a findElement method of the RadToolBar client-side object.

    I hope this helps,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Craig
    Craig avatar
    14 posts
    Member since:
    Sep 2008

    Posted 11 Dec 2008 Link to this post

    Could you point me to the API reference where this says it's supported.  When I view methods for the 

    $telerik object...I only see findCONTROL. There doesn't seem to be a findElement. I just get a script error. Is this a Q3 item?

  5. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Dec 2008 Link to this post

    Hello Craig,

    Yest this is supported from Q3. Since this forum thread has the Q3 version specified I presumed this was the version being used.

    Kind regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Craig
    Craig avatar
    14 posts
    Member since:
    Sep 2008

    Posted 12 Dec 2008 Link to this post

    I didn't see where the forum said q3. Is there a q2 solution?
  7. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 12 Dec 2008 Link to this post

    Hello Craig,

    Here is the actual implementation of the findElement function. You can use it:

        function findElement(parent, id)
        {
            var children = parent.getElementsByTagName("*");
            for(var i = 0, l = children.length; i < l; i++)
            {
                var childID = children[i].id;
                if (childID && childID.endsWith(id))
                    return $get(childID);
            }
           
            return null;
        }

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017