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

Forums / Developing with Sitefinity / Web Application Project and Custom Module

Web Application Project and Custom Module

7 posts, 0 answered
  1. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    10 Aug 2010
    Link to this post
    Hi

    I've converted a SiteFinity app from a Website to a WebApplicationProject. It all works great..except

    I used to have in my App_Code a class called MaterialsModule which inherits from the base class WebModule.

    Problem: SiteFinity doesn't automagically see this class any more

    I've tried adding a namespace to the class and adding it to the code behind here (which is the page where I'm expecting this MaterialModule page to show)

    http://localhost/fmwebapp1/Sitefinity/Admin/Modules.aspx

    public class MaterialsModule : WebModule
    {
       
    public MaterialsModule()
       
    {
       
    }

       
    public override IList<Telerik.Web.IToolboxItem> Controls
       
    {
           
    get
           
    {
               
    return new List<IToolboxItem>(
                   
    new ToolboxItem[]
                   
    {
                       
    new CmsToolboxItem("~/Custom/Modules/Materials/Frontend/Controls/MaterialsList.ascx", "Materials", "Materials List", "Displays list of all materials")
                   
    });
           
    }
       
    }

       
    public override string Description
       
    {
           
    get { return "This is the Materials Module"; }
       
    }

       
    public override string Name
       
    {
           
    get { return "Materials"; }
       
    }

       
    public override string Title
       
    {
           
    get { return "Materials"; }
       
    }

       
    public override System.Web.UI.Control CreateControlPanel(System.Web.UI.TemplateControl parent)
       
    {
           
    return new MaterialsControlPanel();
       
    }

  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    11 Aug 2010
    Link to this post
    Hi Dave Mateer,

    Thank you for using our services.

    One of the differences between Web Application Project and a Website Project is that any changes in code do not get reflected automatically. Your project has to be built every time there is a change in the code and markup. This is not a problem of Sitefinity but rather from the nature of the project. Have you tried to build your project first?

    Sincerely yours,
    Radoslav Georgiev
    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
  3. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    11 Aug 2010
    Link to this post
    Hi Radoslav Georgiev 

    Thanks for the reply.  Understood on the Web Application Project differences.  Yes, I have rebuilt my project.  So after a compile it should work fine?  There is no place where I have to tell SiteFinity to use my new Class (other than my class extending WebModule)?

    Regards

    Dave
  4. Steve
    Steve avatar
    3037 posts
    Registered:
    03 Dec 2008
    11 Aug 2010
    Link to this post
    It shouldn't take any extra re-jiggering really...App_Code is just a way for a website project to allow classes to be shared around...webapp doesnt have that limitation

    If you rebuild, then make a new .cs file somewhere, do you have access to see the MaterialsModule...like does intellisense see it?
  5. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    11 Aug 2010
    Link to this post
    Hi Steve

    Many thanks for replying!  


    I found that if I put in app_code into the web application project, and the module file, it all seems to work again.  Strange.

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
     
    /// <summary>
    /// Summary description for ContactModule
    /// </summary>
    public class ContactModule : Telerik.WebModule
    {
        public ContactModule()
        {
            //
            // TODO: Add constructor logic here
            //
        }
     
        public override IList<Telerik.Web.IToolboxItem> Controls
        {
            get { return null; }
        }
     
        public override string Description
        {
            get { return "This is the Contacts"; }
        }
     
        public override string Name
        {
            get { return "Contacts"; }
        }
     
        public override string Title
        {
            get { return "Contacts"; }
        }
    }

    I've also found that if I keep all the other custom intra-module files outside of app_code (ie dbml, controlPanel) then it works too.

    Cheers

  6. George
    George  avatar
    204 posts
    Registered:
    05 Sep 2006
    12 Aug 2010
    Link to this post
    Hi Dave,

    In a web application project you shouldn't use app_code for your code files. I am not sure how you did it probably you created a normal folder because in a web application you can't create an app_code from the new ASP.NET folder context menu.

     I use Sitefinity with web application projects and I never had this problem before. Try the following, add a new class library project to your solution, move the web module declaration to the new class library, add the needed references (including sitefinity's references) for the new class library to build properly. Now you need to reference your library in the Sitefinity's web application project. After that open your web.config locate the modules where generic content and news are added and add the following

    <add type="MyClassLibrary.CustomModule, MyClassLibrary"/>

    It should work.

    Best,

    G
  7. Dave Mateer
    Dave Mateer avatar
    15 posts
    Registered:
    07 Apr 2010
    22 Aug 2010
    Link to this post
    Hi George

    Cheers for getting back to me.. www.programgood.net/screen7.jpg

    I'm getting stuff in the same project..

    Tried this:

    <modules>
            <add type="Telerik.Cms.Engine.GenericContentModule, Telerik.Cms.Engine"/>
            <add type="Telerik.News.NewsModule, Telerik.News"/>
            <add type="Telerik.Blogs.BlogsModule, Telerik.Blogs"/>
            <add type="Telerik.Lists.ListModule, Telerik.Lists"/>
            <add type="Telerik.Polls.PollModule, Telerik.Polls"/>
            <add type="Telerik.Forums.ForumsModule, Telerik.Forums"/>
            <add type="Telerik.Libraries.LibrariesModule, Telerik.Libraries"/>
            <add type="Telerik.Events.EventsModule, Telerik.Events"/>
            <add type="Telerik.Notifications.Newsletters.NewsletterModule, Telerik.Notifications"/>
            <add type="Telerik.Wiki.WikiModule, Telerik.Wiki"/>
            <add type="MaterialsModule, MaterialsModule"/>
          </modules>

    Then got
    Could not load file or assembly 'MaterialsModule' or one of its dependencies. The system cannot find the file specified.

    No big drama... it works.. just interested now how to refactor to make it cleaner :-)

    Cheers

    Dave
Register for webinar
7 posts, 0 answered