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

Accessing Toolbar client template controls.

5 Answers 132 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Craig
Top achievements
Rank 1
Craig asked on 10 Dec 2008, 10:52 PM
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);

}

 

 

5 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 11 Dec 2008, 05:48 PM
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.
0
Craig
Top achievements
Rank 1
answered on 12 Dec 2008, 12:23 AM
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?

0
Atanas Korchev
Telerik team
answered on 12 Dec 2008, 09:42 AM
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.
0
Craig
Top achievements
Rank 1
answered on 12 Dec 2008, 04:04 PM
I didn't see where the forum said q3. Is there a q2 solution?
0
Atanas Korchev
Telerik team
answered on 12 Dec 2008, 05:04 PM
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.
Tags
ToolBar
Asked by
Craig
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Craig
Top achievements
Rank 1
Share this question
or