RadDock DockCommand AutoPostBack

6 posts, 0 answers
  1. shimon
    shimon avatar
    37 posts
    Member since:
    Apr 2007

    Posted 16 May 2007 Link to this post

    Hello,

    We have so difficulties with the AutoPostBack of DockCommand.
    As i work on the dynamic docks i add a command to the dock and update panel, i need it to postback after the client opens a rad window.
    the opening of the rad window and close is ok, but after it closes i need to do the post back.
    i tried to set it to true on client side and do the doPostBack but it returns this error:
    Microsoft JScript runtime error: Object doesn't support this property or method

    How can i do the postback of a command after the client side command?

    Thanks,
    Shimon
  2. Alex Peachey
    Alex Peachey avatar
    56 posts
    Member since:
    May 2006

    Posted 16 May 2007 Link to this post

    Well, if I understand correctly, you are creating a dynamic dock and you want to have the close command create a postback and handle it.

    RadDock dock = new RadDock();
    // Do some setup on the dock
    dock.AutoPostBack = true;
    dock.Command += new DockCommandEventHandler(dock_Command);

    Then code up your event handler:
    void dock_Command(object sender, DockCommandEventArgs e)
    {
        if (e.Command.GetType() == typeof(DockCloseCommand))
            {
                  //Do some stuff if it was a close.
            }
    }

    That should work. If it doesn't you might have to explicitly set the Close Command to AutoPostBack = true.
    If that's the case, then during dock creation, you can just cycle over the dock.Commands collection and set the DockCloseCommand to AutoPostBack.

  3. shimon
    shimon avatar
    37 posts
    Member since:
    Apr 2007

    Posted 16 May 2007 Link to this post

    Hello,

    1. I create a dynamic dock with a command:
    private RadDock CreateRadDock(string Title)
    {
    int docksCount = CurrentDockStates.Count;
    RadDock dock = new RadDock();
    dock.ID = string.Format("RadDock{0}", docksCount);
    dock.Title = Title;
    dock.Text = string.Format("Added at {0}", DateTime.Now);
    dock.UniqueName = Guid.NewGuid().ToString();
    dock.Width = Unit.Pixel(400);
    dock.Command += new DockCommandEventHandler(dock_Command);
    dock.Commands.Add(new DockCloseCommand());
    DockCommand DockCommand = new DockCommand();
    DockCommand.AutoPostBack = true;
    DockCommand.OnClientCommand = "OpenMasterBoxEditor";
    DockCommand.Name = "Edit";
    dock.Commands.Add(DockCommand);
    return dock;
    }
    void dock_Command(object sender, DockCommandEventArgs e)
    {
    throw new Exception("The method or operation is not implemented.");
    }

    2. I add a postback trigger:
    private void CreateDockCommandTrigger(RadDock dock)
    {
    AsyncPostBackTrigger CommandTrigger = new AsyncPostBackTrigger();
    CommandTrigger.ControlID = dock.ID;
    CommandTrigger.EventName = "Command";
    UpdatePanel2.Triggers.Add(CommandTrigger);
    }

    3. On client side I open a rad window as a dialog with the command:
    OnClientCommand = "OpenMasterBoxEditor";

    4. after I close the rad window I want the rad dock command to postback. It doesn't.

    All the clint side public methods don’t work:
    var cmd = radDock.getCommand("Edit ");
    cmd.doPostBack();

    it returns:
    Microsoft JScript runtime error: Object doesn't support this property or method

    On every client side method.

    can you help with that?

    Thanks,
    Shimon

  4. Alex Peachey
    Alex Peachey avatar
    56 posts
    Member since:
    May 2006

    Posted 16 May 2007 Link to this post

    Ah, I see, I did misunderstand. So you have a command on your dock that opens a RadWindow, and you want to cause a PostBack of the dock when the RadWindow is closed. That does sound quite complicated and I'm not sure the best way for you to get that to happen.
    Others may have some ideas, but the only suggestion I can give further is that perhaps what you are trying to do can be done an alternate way. You might look at the logic flow of the actions and perhaps there is something else that can be causing the PostBack instead of tying it to the close of the window and forcing it on the Dock.

  5. Petya
    Admin
    Petya avatar
    869 posts

    Posted 23 May 2007 Link to this post

    Hi,

    We truly apologize for the delayed answer. So I will not waste more time but get straight to the point. Here is our suggestion:

    [ASPX]

       <script type="text/javascript">
        function OpenMasterBoxEditor(sender, args)
        {
            var oWnd = window.radopen(null, "RadWindow1");
            oWnd.Argument = sender.get_parent();
            return false;
        }
       
        function OnClientClose(radwindow)
        {
            var dock = radwindow.Argument;
            dock.doPostBack("Edit");
        }
        </script>

    where we have removed DockCommand.AutoPostBack = true; from code-behind. The rest of the code is just like our Dynamically Created Docks online example plus your code. I am attaching the project so you can test with it.

    Kind regards,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. shimon
    shimon avatar
    37 posts
    Member since:
    Apr 2007

    Posted 23 May 2007 Link to this post

    Thank you very much, that worked great.

    Thank you,
    Shimon
Back to Top