DockCommand doesn't work

4 posts, 0 answers
  1. Eric Jones
    Eric Jones avatar
    2 posts
    Member since:
    Jan 2008

    Posted 19 Feb 2008 Link to this post

    For some reason when I add a dock command to the commands collections it doesn't get added in the source code for my webpage.  What's odd is that if you go back and look at the "collections" property in VS2008 it shows up - the command that is.  So, I thought I would try to add the <telerik:DockCommand /> directly to the source.  That throws an error creating control error in the IDE.  The following is the specific error "No 'runat=server' attribute present on the dockcommand tag."  Has anyone experienced this?
  2. Sophy
    Admin
    Sophy avatar
    636 posts

    Posted 20 Feb 2008 Link to this post

    Hello,

    Thank you for contacting us.

    There should not be a problem in adding commands to a dock control in the aspx page in the way you mention. I am not sure what may be the reason for experiencing the error you describe. However, right now there is a problem with RadDock commands. They should be recreated at every postback as their state is not preserved in the view state. For example, if you add some commands at a button click event if you do not save them in the view state with some custom code these commands will not exist after postback. We have added this issue in our bug tracking system for further consideration. For your convenience, I have attached a page which demonstrates how you can add commands in the aspx page as well as dynamically in the code-behind.

    However, if you experience different problems from the mentioned above, please, send me a simple running application which reproduces them providing more details about what you want to achieve and what are the problems you experience. I would like to also ask you for a list of steps for reproducing the problems. When we receive all these we will do our best to help you ASAP.


    Best regards,
    Sophy
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. adam
    adam avatar
    20 posts
    Member since:
    Dec 2007

    Posted 26 Feb 2008 Link to this post

    I am having a problem with DockCommands not working also.

    My scenario is a bit different.

    On Page.Init, I am calling the function below for all of the docks on the page.

    private void ApplyDockingMode(RadDock dock, Constants.Dock.Mode value) 
     
        // If the mode is locked, remove all commands and disable dragging. 
        switch (value) 
        { 
            case Constants.Dock.Mode.Locked: 
                dock.Commands.Clear(); 
                dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.None; 
                dock.EnableDrag = false
     
                // Disable the splitter bars 
                this.RadSplitBars.ForEach(splitBar => splitBar.Visible = false); 
                this.RadSplitBars.ForEach(splitBar => splitBar.CollapseMode = SplitBarCollapseMode.None); 
     
                // Lock the panes. 
                this.RadPanes.ForEach(radPane => radPane.Locked = true); 
                break
            case Constants.Dock.Mode.Edit: 
                dock.Commands.Clear(); 
     
                dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.Close | Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse; 
     
                DockCloseCommand closeCommand = new DockCloseCommand(); 
                closeCommand.AutoPostBack = true
                dock.Commands.Add(closeCommand); 
     
                DockExpandCollapseCommand expandCollapseCommand = new DockExpandCollapseCommand(); 
                expandCollapseCommand.AutoPostBack = true
                dock.Commands.Add(expandCollapseCommand); 
     
                DockCommand editCommand = new DockCommand(); 
                editCommand.AutoPostBack = true
                editCommand.Name = "Edit"
                editCommand.Text = "Edit Settings"
                dock.Commands.Add(editCommand); 
     
                dock.EnableDrag = true
     
                // enable the splitter bars. 
                this.RadSplitBars.ForEach(splitBar => splitBar.Visible = true); 
                this.RadSplitBars.ForEach(splitBar => splitBar.CollapseMode = SplitBarCollapseMode.Both); 
     
                // Unlock the panes. 
                this.RadPanes.ForEach(radPane => radPane.Locked = false); 
                break
            default
                throw new InvalidOperationException(string.Concat("The DockMode=", value, " is not supported.")); 
        } 

    That allows me to have the docks either in "Edit" mode or "Locked" mode.

    After I call this function to set the docks in "Edit" mode, then if I use one of the commands (Close, collapse, edit, move) they work as expected, but then their functionality seems to go away (but their icons remain) and I can not do it again unless I reload the page.  At first glance, is there something I am doing wrong here? 

    I am performing that function on every PostBack in the Page Init event handler.

    Is this related to the above problem that Sophy spoke of?

  4. Petio Petkov
    Admin
    Petio Petkov avatar
    825 posts

    Posted 04 Mar 2008 Link to this post

    Hello adam,

    We tried the following code and everything works as expected:

     protected override void OnInit(EventArgs e)  
           {  
               base.OnInit(e);  
               RadDock dock = new RadDock();  
               dock.Text = dock.ID = dock.Title = "aaaa";  
               dock.EnableDrag = true;  
               RadDockZone1.Controls.Add(dock);  
                
                   dock.Commands.Clear();  
     
                   dock.DefaultCommands = Telerik.Web.UI.Dock.DefaultCommands.Close | Telerik.Web.UI.Dock.DefaultCommands.ExpandCollapse;  
     
                   DockCloseCommand closeCommand = new DockCloseCommand();  
                   closeCommand.AutoPostBack = true;  
                   dock.Commands.Add(closeCommand);  
     
                   DockExpandCollapseCommand expandCollapseCommand = new DockExpandCollapseCommand();  
                   expandCollapseCommand.AutoPostBack = true;  
                   dock.Commands.Add(expandCollapseCommand);  
     
                   DockCommand editCommand = new DockCommand();  
                   editCommand.AutoPostBack = true;  
                   editCommand.Name = "Edit";  
                   editCommand.Text = "Edit Settings";  
                   dock.Commands.Add(editCommand);  
           } 

    Please, bear in mind that you should recreate RadDock commands on every postback (As Sophy mentioned before). However if you still have this problem please create a simple running project, where we can observe the problem and send it to us. Once we receive it, we will do our best to help you.

    Greetings,
    Petio Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top