How can I call a javascript function when a dock is expanded or collapsed?

3 posts, 1 answers
  1. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 23 Sep 2013 Link to this post

    Hi,

    I am using version Q2 717 2013 of the ASP.NET for AJAX controls.

    I'm using the RadDock.

    I don't see a client event that I can assign a function to, for when the user clicks the expand / collapse button.  Is there one?

    FYI:  I've implemented a custom close button, so I've also added the following line of code in code-behind, to add the expand / collapse button.

    		dock.Commands.Add(New DockExpandCollapseCommand())
    

    Again, my goal / question is:  I want to run some client-side code (NOT do a postback) after the user has expanded or collapsed a dock.  How can I do that?

    Thanks,
    Brent
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Sep 2013 Link to this post

    Hi Brent Hetland,

    Please have a look at the following code snippet I have tried to invoke the client side event for Expand/Collapse button of RadDock.

    ASPX:
    <telerik:RadDock ID="RadDock1" runat="server" Title="Item1">
        <Commands>
            <telerik:DockExpandCollapseCommand OnClientCommand="OnClientCommand" />
        </Commands>
        <ContentTemplate>
            <telerik:RadTextBox ID="RadTextBox1" runat="server">
            </telerik:RadTextBox>
            <br />
            <br />
            <telerik:RadButton ID="RadButton1" runat="server" Text="demo">
            </telerik:RadButton>
        </ContentTemplate>
    </telerik:RadDock>

    JavaScript:
    <script type="text/javascript">
        function OnClientCommand(sender, args) {
            if (args.command._clientTypeName == "Telerik.Web.UI.DockExpandCollapseCommand") {
                alert("Fired");
            }
        }
    </script>

    Thanks,
    Shinu
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Brent Hetland
    Brent Hetland avatar
    61 posts
    Member since:
    Aug 2009

    Posted 24 Sep 2013 Link to this post

    I'm adding my raddocks dynamically in code behind, so I did it like this and it works.  Thanks Much!

    		Dim ExpandCollapseCommand As DockExpandCollapseCommand = New DockExpandCollapseCommand()
    		ExpandCollapseCommand.OnClientCommand = "OnClientCommand"
    		dock.Commands.Add(ExpandCollapseCommand)
    

Back to Top