"Error parsing the template" - Data doesn't appear on website
Look at my code below:
----------------------------------------------------------
1) MasterListView.ascx
<%@ Control Language="C#" %>
<%@ Register Assembly="Telerik.Sitefinity, Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" TagPrefix="sf" %>
<%@ Register Assembly="Telerik.Sitefinity, Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" Namespace="Telerik.Sitefinity.Web.UI" TagPrefix="sf" %>
<%@ Register Assembly="Telerik.Web.UI, Version=2011.2.712.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<h1>Testimonials</h1>
<telerik:RadListView ID="TestimonialsList"
ItemPlaceholderID="ItemsContainer" GroupPlaceholderID="GroupContainer" GroupItemCount="3" runat="server"
EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
<LayoutTemplate>
<div class="Testimonials">
<asp:PlaceHolder ID="GroupContainer" runat="server" />
</div>
</LayoutTemplate>
<GroupTemplate>
<div class="row">
<asp:PlaceHolder ID="ItemsContainer" runat="server" />
</div>
</GroupTemplate>
<ItemTemplate>
<div class="column-small">
<div class="block">
<h3><sf:DetailsViewHyperLink ID="DetailsViewHyperLink" TextDataField="Title" ToolTipDataField="Description" runat="server" /></h3>
<testimonial>
<sf:FieldListView ID="ClientName" runat="server" Text="0" Properties="ClientName" /><br />
<sf:FieldListView ID="TestimonialText" runat="server" Text="0" Properties="TestimonialText" />
</testimonial>
</div>
</div>
</ItemTemplate>
</telerik:RadListView>
<sf:Pager id="pager" runat="server" />
----------------------------------------------------------
2) MasterListView.cs
namespace Testimonials.PublicControls
public class MasterListView : ViewBase
#region Override Template Properties
protected override string LayoutTemplateName
get return null;
public override string LayoutTemplatePath
get
var path = TestimonialsModule.TestimonialsVirtualPath + layoutTemplateName;
return path;
set
base.LayoutTemplatePath = value;
#endregion
private TestimonialsManager manager;
protected TestimonialsManager Manager
get
if (this.manager == null)
this.manager = TestimonialsManager.GetManager(this.Host.ControlDefinition.ProviderName);
return this.manager;
#region Control References
protected internal virtual RadListView TestimonialsListControl
get
return this.Container.GetControl<RadListView>("TestimonialsList", true);
protected internal virtual Pager Pager
get
return this.Container.GetControl<Pager>("pager", true);
#endregion
#region Methods
protected override void InitializeControls(GenericContainer container, IContentViewDefinition definition)
try
// ensure a valid definition is passed
var masterDefinition = definition as IContentViewMasterDefinition;
if (masterDefinition == null) return;
// retrieve Testimonials from the manager
var manager = TestimonialsManager.GetManager(this.Host.ControlDefinition.ProviderName);
var query = manager.GetTestimonials();
// modify pager based on query results
int? totalCount = 0;
int? itemsToSkip = 0;
if (masterDefinition.AllowPaging.HasValue && masterDefinition.AllowPaging.Value)
itemsToSkip = this.GetItemsToSkipCount(masterDefinition.ItemsPerPage, this.Host.UrlEvaluationMode, this.Host.UrlKeyPrefix);
// culture for Urls in pager
CultureInfo uiCulture = null;
if (Config.Get<ResourcesConfig>().Multilingual)
uiCulture = System.Globalization.CultureInfo.CurrentUICulture;
// check for additional filters set by the definition
var filterExpression = String.Empty;
// modify the query with everything from above
query = Telerik.Sitefinity.Data.DataProviderBase.SetExpressions(
query,
filterExpression,
masterDefinition.SortExpression,
uiCulture,
itemsToSkip,
masterDefinition.ItemsPerPage,
ref totalCount);
this.IsEmptyView = (totalCount == 0);
// display results
if (totalCount == 0)
this.TestimonialsListControl.Visible = false;
else
this.ConfigurePager(totalCount.Value, masterDefinition);
System.Collections.Generic.List<Testimonial> list = query.ToList();
this.TestimonialsListControl.DataSource = list;
catch(Exception ex)
protected virtual void ConfigurePager(int virtualItemCount, IContentViewMasterDefinition masterDefinition)
if (masterDefinition.AllowPaging.HasValue &&
masterDefinition.AllowPaging.Value &&
masterDefinition.ItemsPerPage.GetValueOrDefault() > 0)
this.Pager.VirtualItemCount = virtualItemCount;
this.Pager.PageSize = masterDefinition.ItemsPerPage.Value;
this.Pager.QueryParamKey = this.Host.UrlKeyPrefix;
else
this.Pager.Visible = false;
#endregion
internal const string layoutTemplateName = "Testimonials.Resources.Views.MasterListView.ascx";
--------------------------------
When I drag and drop this control it gives me error "Error parsing the template" in sitefinity backend editor. And I dont get any testimonial binded in telerik:RadListView. I just get "<h1>Testimonials</h1>" in output.
When I debug below lines, I found "list" contains true data. but it doesn't show in RadListView.
System.Collections.Generic.List<Testimonial> list = query.ToList();
this.TestimonialsListControl.DataSource = list;
Where I am doing wrong?
I am having the exact same problem. I have triple checked - the controls Build Action is set as "Embedded Resource" but I still get the same Error parsing the template error.
Also the VirtualPath settings seem to be fine:
Here's my path in the MasterListView.cs
public override string LayoutTemplatePath
get
var path = "~/HomepageRotatorTemplates/HomepageRotatorModule.Web.UI.Public.Resources.MasterListView.ascx";
return path;
set
base.LayoutTemplatePath = value;
private void InstallCustomVirtualPaths(SiteInitializer initializer)
var virtualPathConfig = initializer.Context.GetConfig<
VirtualPathSettingsConfig
>();
ConfigManager.Executed += new EventHandler<
ExecutedEventArgs
>(ConfigManager_Executed);
var homapegeRotatorModuleVirtualPathConfig = new VirtualPathElement(virtualPathConfig.VirtualPaths)
VirtualPath = "~/HomepageRotatorTemplates/*",
ResolverName = "EmbeddedResourceResolver",
ResourceLocation = "HomepageRotatorModule"
;
if (!virtualPathConfig.VirtualPaths.ContainsKey("~/HomepageRotatorTemplates/*"))
virtualPathConfig.VirtualPaths.Add(homapegeRotatorModuleVirtualPathConfig);
Hi Vaibhavi,
Did you try removing the following parts from your Register clauses:
", Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563"
and leave just the name of the assembly.
I do not have the versions in my registry clauses and Ive even modifed my MasterListView.cs to the code below, still I get the same error.
public override string LayoutTemplatePath
get
var path = "~/HomepageRotatorTemplates/" + layoutTemplateName;
return path;
set
base.LayoutTemplatePath = value;
internal const string layoutTemplateName = "HomepageRotatorModule.Web.UI.Public.Resources.MasterListView.ascx";
I tried removing the ", Version=4.2.1733.0, Culture=neutral, PublicKeyToken=b28c218413bdf563" but getting same error.
Hi Vaibhavi,
I attached a small class library project that uses your control and its template. You also need to fix the references, add a reference to this control from your main SitefinityWebApp and add the following virtual path setting:
VirtualPath - "~/CustomWidgets/*"
ResourceLocation - "CustomWidgets"
ResolverName - "EmbeddedResourceResolver"
This setup was working for me and I got no error.