More in this section

Forums / Developing with Sitefinity / Advice for building an Admin Module

Advice for building an Admin Module

5 posts, 0 answered
  1. Carl
    Carl avatar
    23 posts
    Registered:
    15 Jul 2008
    03 Sep 2008
    Link to this post
    I was just wondering, for the Admin section of a module, do we have to use web user controls without the code behind, and place all of our code within the CommandPanel and ControlPanel classes? Or is there a way from the code behind, to call base.ControlPanel.Refresh();

    If most of the code can be placed within seperate web user controls, this would help manage the code, as well as help speed up the development, because restarts of the applications would be needed as much.

    Thanks,
    Carl J


  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Sep 2008
    Link to this post
    Hi Carl,

    Sitefinity supports two kinds of modules:

    Both types are capable of achieving the same end functionality and the only difference is in the actual implementation.

    Intra-Site modules are much simpler and quicker to develop. The code for these modules is stored in the App_Code folder, while the user interface is implemented through series of User Controls.

    Pluggable modules are a bit more complex to implement. The whole Pluggable module is compiled into a .dll file, together with the User Interface elements (generally, composite controls). 

    So you will choose the appropriate type of a custom module depending on your particular needs. For more information on this matter please refer to the following topic of the Developer Manual.

    Regarding your question about refreshing the base Control Panel, here is a simple example:

    ControlPanel ctrlPnl = ((ControlPanel)base.ControlPanel); 
    ctrlPnl.Refresh(); 

    Do let us know if you need any further assistance.

    Best wishes,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Carl
    Carl avatar
    23 posts
    Registered:
    15 Jul 2008
    04 Sep 2008
    Link to this post
    Hi Pepi, thank you for your response.

    The type of module that I'm developing is a Pluggable module, which was build using the downloadable Visual Studio template. The module uses control templates without the code behind, as well as the Command Panel and Control Panel classes. The reason why I was asking, is because currently the Control Panel class is 3286 lines (of course some of those are from comments), and there is still quite a  bit of work to do.

    Personally, I find the size to be a bit too much, and makes it harder to keep everything clean and organized.

    I was hoping to be able to use the code behind of the user controls, and place more of the code from the control panel class within the user controls.

    This seemed to work until I needed to set the ((ControlPanel)(base.ControlPanel)).DisplayMode and then do a  base.ControlPanel.Refresh(); to change the control (user clicks on an item in a RadGrid, which then brings them to a page where they can edit that Item). However, I can't do that because the UserControl doesn't have access to the ControlPanel class (or can it?).

    Is there a cleaner way to seperate the code and still go the Pluggable way? Or will I be stuck with 5000+ lines of code within the ControlPanel?

    Thanks again,
    Carl J
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    04 Sep 2008
    Link to this post
    Hi Carl,

    We do not recommend you separate the code of the Control Panel class in the described way (using the code behind of the user controls). Please note that .ascx files in the Pluggable modules are used as templates and not as user controls.

    Here are some good practices how to make your code more clean and readable:
       1. Consider refactoring the code into helper classes
       2. Use regions to organize the code logically:

    #region Properties 
    ... 
    #endregion 

       3. Do not write comments for every line of code and every variable declared. Write comments wherever required. If all variables and method names are meaningful, that will make the code very readable and it will not need much commenting.

    Hope this is helpful for you.

    Greetings,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Adam
    Adam avatar
    63 posts
    Registered:
    30 Jan 2008
    27 Sep 2008
    Link to this post

     

    Carl,

    You can also use partial classes to help break up the class into easier to digest areas.

    Adam
Register for webinar
5 posts, 0 answered