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

Access control inside RadDock from javascript

1 Answer 152 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Serial Killer
Top achievements
Rank 1
Serial Killer asked on 25 Jan 2011, 01:44 PM
Hello! I has faced such problem. I try to get access to control being inside RadDock using JavaScript. I do it as follows...

<script type="text/javascript">

var test = $find("<%=RadDock1.ContentContainer.FindControl("val1").ClientID %>");

</script>

 <telerik:RadDock ID="RadDock1" runat="server" Width="300px">
        <ContentTemplate>

        <telerik:RadTextBox ID="val1" runat="server">
        </telerik:RadTextBox>

</ContentTemplate>
</telerik:RadDock>

When page generated, i cannot get access to control, and its "null" because if look html code i see the following...

<span id="RadDock1_C_val1_wrapper" class="RadInput RadInput_Default" style="white-space:nowrap;">
<input type="text" size="20" id="RadDock1_C_val1_text" name="RadDock1_C_val1_text" class="riTextBox riEnabled" style="width:125px;" />
<input id="RadDock1_C_val1" name="RadDock1$C$val1" class="rdfd_" style="visibility:hidden;margin:-18px 0 0 -1px;width:1px;height:1px;overflow:hidden;border:0;padding:0;" type="text" value="" />
<input id="RadDock1_C_val1_ClientState" name="RadDock1_C_val1_ClientState" type="hidden" /></span>
And my javascript code - var test = $find("<%=RadDock1.ContentContainer.FindControl("val1").ClientID %>");
find this control - RadDock1_C_val1 but it is null. How can i get access to this control - RadDock1_C_val1_text ??? what i do not so??

Thanks!

1 Answer, 1 is accepted

Sort by
0
Pero
Telerik team
answered on 26 Jan 2011, 02:58 PM
Hi,

I believe the problem comes from the fact that the RadDock's ContentTemplate is not initialized when you try to access some of its child controls, and that's why you can't get a reference to the RadTextBox. I would suggest to directly use the RadTextBox control, to get its client id.
The following code works without a problem on my side:
<script type="text/javascript">
    function pageLoad()
    {
        var test = $find('<%=val1.ClientID %>');
        alert(test.get_id());
    }
</script>
<telerik:RadDock ID="RadDock3" runat="server" Width="300px">
    <ContentTemplate>
        <telerik:RadTextBox ID="val1" runat="server">
        </telerik:RadTextBox>
    </ContentTemplate>
</telerik:RadDock>


Greetings,
Pero
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Dock
Asked by
Serial Killer
Top achievements
Rank 1
Answers by
Pero
Telerik team
Share this question
or