Dynamic Custom Doc Command

6 posts, 0 answers
  1. Stephen
    Stephen avatar
    38 posts
    Member since:
    Mar 2008

    Posted 20 Nov 2008 Link to this post

    Anyone have any suggestions on how to add a dock command server-side. I'm creating the commands on the fly and want to add a "reload" button (there is one on the RadWindow) and then handle that myself. But I can't seem to create a DockCommand.
    Telerik.Web.UI.DockCommand.DockCommand(string, string, string, string, bool)' is inaccessible due to its protection level   


  2. Vyrban
    Vyrban avatar
    31 posts
    Member since:
    Nov 2008

    Posted 21 Nov 2008 Link to this post

    Hi Stephen,

    You can use this:
    dock.Commands.Add(new DockCloseCommand());  
    dock.Commands.Add(new DockExpandCollapseCommand());  
    dock.Command += new DockCommandEventHandler(dock_Command);  
     
    //..........  
     
    void dock_Command(object sender, DockCommandEventArgs e)  
    {  
    //.......  
    The code is form Telerik online RadDock example "My portal".
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Stephen
    Stephen avatar
    38 posts
    Member since:
    Mar 2008

    Posted 21 Nov 2008 Link to this post

    I think I had seen that. What I want to do is add a new command. I think what you described just adds the command from the existing set (Close, Pin, Expand/Collapse). I need to add a new icon to enable different functionality. If you think I can do that with what you suggested I'll look over that again as I must be missing something.
  5. Vyrban
    Vyrban avatar
    31 posts
    Member since:
    Nov 2008

    Posted 21 Nov 2008 Link to this post

    Hi Stephen,

    Of course these are the default commands. For Custom Command "Reload" You can use this code:
    protected void Page_Load(object sender, EventArgs e)  
        {  
            DockCommand command = new DockCommand();  
            command.Name = "Reload";  
            RadDock1.Command += new DockCommandEventHandler(RadDock1_Command);  
            RadDock1.Commands.Add(command);  
            RadDock1.CommandsAutoPostBack = true;  
        }  
     
        void RadDock1_Command(object sender, DockCommandEventArgs e)  
        {  
            if (e.Command.Name == "Reload")  
            {  
                //Do what is supposed to do     
            }  
        } 
    Think this will help you :)
  6. Derek Bemis
    Derek Bemis avatar
    14 posts
    Member since:
    Sep 2009

    Posted 09 Feb 2010 Link to this post

    I have almost this exact code and for the life of me I can't get the function to fire, the page never posts back.

    Do you see anything wrong here?

    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;
            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

    protected void Dock_Command(object sender, DockCommandEventArgs e)
        {
            Response.Redirect("alskfj alsdjf lasj lasdjf lasjfk");
        }

    The redirect never fires, why?

    Thanks,
    Derek

  7. Pero
    Admin
    Pero avatar
    1156 posts

    Posted 12 Feb 2010 Link to this post

    Hi Derek,

    Please check 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.

    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
UI for ASP.NET Ajax is Ready for VS 2017