Cannot find template
Hi,
I'm developing custom widget for Sitefinity 4.1 and I follow the documentation. Somehow I encountered this error
Server Error in '/' Application.
Cannot find template "~/SFERegistration/ERegistrationModule.Resources.Views.EventItemList.ascx".
Description: An unhandled exception occurred during
the execution of the current web request. Please review the stack trace
for more information about the error and where it originated in the
code.
Exception Details: System.ArgumentException: Cannot find template "~/SFERegistration/ERegistrationModule.Resources.Views.EventItemList.ascx".
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentException: Cannot find template "~/SFERegistration/ERegistrationModule.Resources.Views.EventItemList.ascx".]
Telerik.Sitefinity.Web.UI.ControlUtilities.GetTemplate(String virtualPath, String resourceFileName, Type assemblyInfo, String templateDeclaration, Boolean addChildrenAsDirectDescendants) +864
Telerik.Sitefinity.Web.UI.ControlUtilities.GetControlTemplate(TemplateInfo info) +437
Telerik.Sitefinity.Web.UI.ControlUtilities.GetTemplate(TemplateInfo info) +1056
Telerik.Sitefinity.Web.UI.SimpleView.get_LayoutTemplate() +119
Telerik.Sitefinity.Web.UI.SimpleView.get_Container() +21
Telerik.Sitefinity.Web.UI.SimpleView.CreateChildControls() +46
System.Web.UI.Control.EnsureChildControls() +102
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Control.PreRenderRecursiveInternal() +175
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2496
I've changed the template path in my widget,
private
const
string
layoutTemplateName =
"ERegistrationModule.Resources.Views.EventItemList.ascx"
;
protected
override
string
LayoutTemplateName
get
return
null
;
public
override
string
LayoutTemplatePath
get
var path = ERegistrationModule.ERegistrationVirtualPath + layoutTemplateName;
return
path;
set
base
.LayoutTemplatePath = value;
public
static
string
ERegistrationVirtualPath =
"~/SFERegistration/"
;
public
override
void
Install(SiteInitializer initializer)
base
.Install(initializer);
InstallCustomVirtualPaths(initializer);
private
void
InstallCustomVirtualPaths(SiteInitializer initialzer)
var virtualPathConfig = initialzer.Context.GetConfig<VirtualPathSettingsConfig>();
var moduleVirtualPathConfig =
new
VirtualPathElement(virtualPathConfig.VirtualPaths)
VirtualPath = ERegistrationModule.ERegistrationVirtualPath +
"*"
,
ResolverName =
"EmbeddedResourceResolver"
,
ResourceLocation =
"ERegistrationModule"
;
if
(!virtualPathConfig.VirtualPaths.ContainsKey(ERegistrationModule.ERegistrationVirtualPath +
"*"
))
virtualPathConfig.VirtualPaths.Add(moduleVirtualPathConfig);
Hi Anton,
1. Check whether the VirtualPathSettingsConfig is updated through the configurations ( Administration>> Settings >> Advanced;)
2. Make sure that your template is built as an embedded resource
3.ResourceLocation is set correctly. Generally is set to the name of the class library like in the default modules Telerik.Sitefinity.Resources
Kind regards,
Ivan Dimitrov
the Telerik team
Hi Ivan,
Thanks for you reply.
I've checked the virtual path and my path is registered (~/SFERegistration/*).
The build action of my .ascx is also already set to Embedded Resource, and my ResourceLocation is set to my class library name (ERegistrationModule).
Btw, I didn't create resource class as in documentation because I don't think that my module will be localized,
so I don't set all the "ResourceClassId" properties. Does this cause the error?
So far it works in backend.
Any other suggestion?
Regards,
Anton
The problem is resolved now. Apparently I put the widget's class (EventItemList) in the same folder as its view (EventItemList.ascx) and they have the same name & namespace, then EmbeddedResourceResolver can't find the .ascx.
Regards,
Anton