Dynamic RadDock and Server Side Custom Command

4 posts, 0 answers
  1. Derek Bemis
    Derek Bemis avatar
    14 posts
    Member since:
    Sep 2009

    Posted 08 Feb 2010 Link to this post

    This sounds simple enough but for the life of me I can't seem to get this wired correctly. I am creating RadDock's dynamically and I want to add Custom DockCommands to the RadDock that will call one of two server side functions. I can never seem to get the server side function to fire, what am I missing?

    Here is an example of how I am creating the RadDock and the subsequent DockCommand.

    RadDock rd = new RadDock();
            rd.ID = usage + "_" + "FORM_" + loadedForm.getID() + "_" + ff.getFormFieldID() + "_" + ffs.getFormFieldSettingsID();
            rd.DockMode = DockMode.Docked;
            rd.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None;
            rd.Width = 300;
            rd.Height = 80;

            DockCommand command = new DockCommand();
            command.AutoPostBack = true;
            command.Name = "Command1";

            rd.Commands.Add(command);

    However, I never get anything in Command1_Command, Command1_Click etc. What piece is missing to cause the Server Side function to fire when a custom command is clicked on the RadDock?

    Thank you,
    Derek

  2. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 10 Feb 2010 Link to this post

    Hi Derek,

    When you explicitly add commands to RadDock you should not set the DefaultCommands property to Telerik.Web.UI.Dock.DefaultCommands.None. Only the added commands will be displayed in the dock's TitleBar.

    To achieve the desired result you should dynamically attach an event handler to the RadDock's Command event and based on the command that fired the event execute the respective method. The following code attaches an event handler to RadDock1's Command event:

    Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Init
        AddHandler RadDock1.Command, AddressOf RadDock1_Command
     
    End Sub
     
    Protected Sub RadDock1_Command(ByVal sender As Object, ByVal e As DockCommandEventArgs)
     
        If e.Command.Text = "" Then
            'Do something
        End If
     
    End Sub


    Regards,
    Pero
    the Telerik team

    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
    Follow the status of features or bugs in PITS and vote for them to affect their priority.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Derek Bemis
    Derek Bemis avatar
    14 posts
    Member since:
    Sep 2009

    Posted 10 Feb 2010 Link to this post

    Here is my latest example that still does not work:

            RadDock rd = new RadDock();
            rd.ID = usage + "_" + "FORM_" + loadedForm.getID() + "_" + ff.getFormFieldID() + "_" + ffs.getFormFieldSettingsID();
            rd.DockMode = DockMode.Docked;
            rd.Width = 300;
            rd.Height = 80;
            rd.AutoPostBack = true;
            rd.CommandsAutoPostBack = true;

            rd.Command += new DockCommandEventHandler(Dock_Command);

            DockCommand command = new DockCommand();
            command.AutoPostBack = true;
            command.Name = "Command1";
            command.Text = "Command1";

            rd.Commands.Add(command);

    And here is the Event Handler:

    protected void Dock_Command(object sender, DockCommandEventArgs e)
        {
            Response.Redirect("test.aspx");
        }

    The problem is the page never posts back when I click the gear icon, never. The Dock_Command event never fires and of course the page never redirects. Why is it not registering the click?

    Also, can you please post examples for this thread in C# if possible?

    Thanks,
    Derek
  5. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 12 Feb 2010 Link to this post

    Hi Derek,

    Everything seems to be configured correctly. One last thing to check is at what stage in the page lifecycle the dock is added to the page. If it's added after the Command event is triggered the code will never be executed.

    I created a sample project and could not reproduce the problem. It is attached to the thread.

    If you still cannot find a solution to your problem, please open a support ticket and send us a sample that demonstrates the issue. We will do our best to help.

    Kind regards,
    Pero
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Back to Top