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

Find raddock clientside object on click of radbutton inside the content template of raddock

4 Answers 80 Views
Dock
This is a migrated thread and some comments may be shown as answers.
Chetan
Top achievements
Rank 1
Chetan asked on 04 Dec 2013, 01:48 AM
Hi I have a radbutton inside content template of the raddock.. How do I get hold of raddock client object on client clicked event of radbutton? Thanks!

4 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Dec 2013, 03:24 AM
Hi Chetan,

Please have a look into the following code snippet to access the RadDock Client side object in RadButton OnClientClicked event.

ASPX:
<telerik:RadDock ID="RadDock1" runat="server">
    <ContentTemplate>
        <telerik:RadButton ID="RadButton1" runat="server" Text="Get RadDock" AutoPostBack="false"
            OnClientClicked="OnClientClicked1">
        </telerik:RadButton>
    </ContentTemplate>
</telerik:RadDock>

JavaScript:
<script type="text/javascript">
    function OnClientClicked1(sender, args) {
        var dock = $find("<%=RadDock1.ClientID %>");
        //your code
    }
</script>

Thanks,
Shinu.
0
Chetan
Top achievements
Rank 1
answered on 04 Dec 2013, 03:01 PM
Thanks Shinu,
But that is not what I am looking for.
Let me explain the scenario.. 

I have 6 radDockZone and each one has atleast 1 RadDock on Initiating. Now that each RadDock has contentTemplate with user Control and this userControl has RadButton And RadTextBox. So I will have to write mulitple clientScripts if I want to use <% RadDock.ClientID %> ..
But Instead I want to use same clientFunction so is there a way that on RadButtonClick I can get something like sender.parentItem.parentItem to get hold of the containing radDock ?
0
Shinu
Top achievements
Rank 2
answered on 05 Dec 2013, 04:58 AM
Hi Chetan,

Please have a look into the sample code snippet which works fine at my end.

ASPX:
<telerik:RadDockZone ID="RadDockZone1" runat="server">
    <telerik:RadDock ID="RadDock1" runat="server" OnClientInitialize="OnClientInitialize1">
        <ContentTemplate>
            <uc1:WebUserControl ID="WebUserControl1" runat="server" />
        </ContentTemplate>
    </telerik:RadDock>
</telerik:RadDockZone>

ASCX:
<telerik:RadTextBox ID="RadTextBox1" runat="server">
</telerik:RadTextBox>
<telerik:RadButton ID="RadButton1" runat="server" Text="Click" AutoPostBack="false"
    OnClientClicked="OnClientClicked">
</telerik:RadButton>

ASPX JavaScript:
<script type="text/javascript">
    var dock;
    function OnClientInitialize1(sender, args) {
        dock = sender;
    }
    function OnClientClicked(sender, args) {
        //the dock variable have all the properties and method of the parent raddock
        alert(dock._uniqueID);
    }
</script>

Hope this will helps you.
Thanks,
Shinu.
0
Chetan
Top achievements
Rank 1
answered on 05 Dec 2013, 04:16 PM
Thanks but this means I have to impletement OnClientInitialize1 ,OnClientInitialize2
OnClientInitialize2,OnClientInitialize3,OnClientInitialize4....one for each RadDock that I have..
I want to use one function for all the RadDocks which can be spread across 6 RaddockZone?




Tags
Dock
Asked by
Chetan
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Chetan
Top achievements
Rank 1
Share this question
or