Developer forum

Forum » Development » Loadcontrol tag does not load my usercontrol

Loadcontrol tag does not load my usercontrol

Lars Larsen
Reply

Hi,

On a DW8 v8.1.2.0 solution I have a usercontrol that I try to get loaded:

namespace CustomModules.ModuleName
{
    [AddInName("MyCustomModule")]
    public class MyCustomModule : Dynamicweb.ContentModule
    {
        public override string GetContent()
        {
            return "<!--@LoadControl(/MyCustomModuleControl.ascx)-->";
        }
    }
}

But the DW does not output my usercontrol (/MyCustomModuleControl.ascx). Instead it outputs the tag: <!--@LoadControl(/MyCustomModuleControl.ascx)-->

Any idea why this is not working?


Replies

 
Morten Bengtson
Reply
This post has been marked as an answer

Hi Lars,

 

If you view source on the page and look at the comment at the bottom does it say something like "ERROR: /MyCustomModuleControl.ascx not found"?

If not then there could be a problem with some code in your control that causes an exception. Have you tried loading a very simple "hello world" usercontrol that does nothing but render some text? Just create a file with "<h1>Hello World</h1>", save as HelloWorld.ascx and then try loading that with the LoadControl tag.

 

/Morten

Votes for this answer: 1
 
Lars Larsen
Reply

Hi Morten

Thanks for your answer. You were right about the ascx. There were an error in the control. The DW control "DateSelector" was used in the ascx, but there are more than one "DateSelector" control in different namespaces in DW. So adding this line solved the problem:

<%@ Register TagPrefix="dw" Namespace="Dynamicweb.Controls" Assembly="Dynamicweb.Controls" %>

But why does DW not output the error from the ascx? It would be nice if one could see the error. Now it is almost impossible to see what is wrong when an ascx fails to load! I think this was the behavior in DW 7.x but obviously not in DW 8.x.

 

You must be logged in to post in the forum