1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Intra-Site module. How to use CommandPanel?

Intra-Site module. How to use CommandPanel?

4 posts, 0 answered
  1. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    30 Dec 2008
    Link to this post
    Hi Guys,

    I want to add to my Intra-Site module some functionality.

    I has found next topics:
    http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-btmhmk.aspx
    and
    http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-hkbdm.aspx
    and blog
    http://blogs.sitefinity.com/Ivan/Post/07-08-14/improvements_in_modules_architecture_in_sitefinity_sp2.aspx

    My problem:
    1. I have UserControl based module (ControlPannel.aspx, ControlPannel.aspx.cs and CommandPannel.aspx, CommandPannel.aspx.cs) files.
    2. I try to add CommandPanel sections, for example, Products, Downloads, Settings and I want to switch ControlPannel view mode.
    3. When I type  this.ControlPanel. (in CommandPannel.aspx.cs) I can not find  public property Mode from ControlPanel.

    I know - I do something wish incorrectly.
    How I can do this?

    Thanks,
    Anton.


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    30 Dec 2008
    Link to this post
    Hi Anton,

    You need to implement the Mode of ControlPanel in your class( for instance CommandPanel.cs). Here is an example below:

      protected virtual void button_Command(object sender, CommandEventArgs e) 
            { 
                // based on the command name, set the Mode of ControlPanel   
                ControlPanel ctrlPnl = ((ControlPanel)base.ControlPanel); 
                switch (e.CommandName) 
                { 
                    case "ContentView"
                        ctrlPnl.Mode = Cms.Engine.WebControls.Admin.ControlPanel.Modes.List; 
                        ctrlPnl.Refresh(); 
                        break
                    case "CategoriesView"
                        ctrlPnl.Mode = Cms.Engine.WebControls.Admin.ControlPanel.Modes.Categories; 
                        ctrlPnl.Refresh(); 
                        break
     
             ..... 

    Let us know if your approach is different.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    30 Dec 2008
    Link to this post
    Thanks for answer, Ivan!

    But now  when I type next code:
    ControlPanel ctrlPnl = ((ControlPanel)base.ControlPanel);

    I have a compiler error:
    Compiler Error Message: CS0117: 'System.Web.UI.UserControl' does not contain a definition for 'ControlPanel'

    I think I get compilation error because my class  based on UserControl class instead of ControlPanel.

    This is my class definition:
    public partial class MyControl : UserControl, ICommandPanel{}
    I has downloaded example of Intra-Site module (Contacts) and try change it.

    How correctly to make it?

    Thanks,
    Anton.
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    31 Dec 2008
    Link to this post
    Hello Anton,

    You can create a property to get and set the current mode of your control panel.

    public DisplayMode Mode 
        { 
            get 
            { 
                if (ViewState["Mode"] == null
                    return DisplayMode.ContactsList; 
                return (DisplayMode)ViewState["Mode"]; 
            } 
            set 
            { 
                ViewState.Add("Mode", value); 
            } 
        } 

    Then, changing the mode of the control.

    private void SwitchMode(DisplayMode mode) 
        { 
            FormView fmwContact = (FormView)insertEdit.FindControl("fmwContact"); 
            this.Mode = mode; 
            switch (mode) 
            { 
                case DisplayMode.ContactsList: 
                    mvwControlPanel.ActiveViewIndex = 0; 
                    this.ctrlPnlTitle = "Contacts";                 
                    break

    In ControlPanel.ascx there is a FormView control with the corresponding ID FormView ID="fmwContact"

    Let us know if I miss something.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
4 posts, 0 answered