Error using event field multiple times in template

Posted by Community Admin on 04-Aug-2018 18:38

Error using event field multiple times in template

All Replies

Posted by Community Admin on 09-Jan-2012 00:00
I've like to display my event time and date in different spots. To do this I've tried to use the following template, but when I do I receive the error message "error parsing the template".

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<telerik:RadListView ID="eventsList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
    <LayoutTemplate>
        <sf:ContentBrowseAndEditToolbar ID="MainBrowseAndEditToolbar" runat="server" Mode="Add"></sf:ContentBrowseAndEditToolbar>    
        <ul class="home-events">
            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </ul>
        <a href="/calendar" class="viewAllLink">View all events</a>
    </LayoutTemplate>
    <ItemTemplate>
        <li>
            <span class="item-date">
                <sf:FieldListView ID="EventStart" runat="server" Format="EventStart.ToLocal(): MMM" />
                <span><sf:FieldListView ID="EventStart" runat="server" Format="  EventStart.ToLocal(): dd" /></span>
            </span>
            <h4>
                <sf:DetailsViewHyperLink TextDataField="Title" ToolTipDataField="Description" runat="server" />
            </h4>
            <p>
                <em>Starts:</em>
                <span class="right-info"><sf:FieldListView ID="EventStart" runat="server" Format="  EventStart.ToLocal(): MMM dd, yyyy" /> @ <sf:FieldListView ID="EventStart" runat="server" Format="  EventStart.ToLocal(): h:mm tt" /></span>
            </p>
            <sf:ContentBrowseAndEditToolbar ID="BrowseAndEditToolbar" runat="server" Mode="Edit,Delete,Unpublish"></sf:ContentBrowseAndEditToolbar>
        </li>
    </ItemTemplate>
</telerik:RadListView>
<sf:Pager id="pager" runat="server"></sf:Pager>

How can I accomplish splitting the event time and date?
Posted by Community Admin on 09-Jan-2012 00:00
Found it! Turns out you have to switch the FieldListView to TextFields to use fields multiple times. Here's what I came up with:

<%@ Control Language="C#" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.Comments" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
 
<telerik:RadListView ID="eventsList" ItemPlaceholderID="ItemsContainer" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
    <LayoutTemplate>
        <sf:ContentBrowseAndEditToolbar ID="MainBrowseAndEditToolbar" runat="server" Mode="Add"></sf:ContentBrowseAndEditToolbar>    
        <ul class="home-events">
            <asp:PlaceHolder ID="ItemsContainer" runat="server" />
        </ul>
        <a href="/calendar" class="viewAllLink">View all events</a>
    </LayoutTemplate>
    <ItemTemplate>
        <li>
            <span class="item-date">
                <sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("MMM") %>' />
                <span><sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("dd") %>' /></span>
            </span>
            <h4>
                <sf:DetailsViewHyperLink TextDataField="Title" ToolTipDataField="Description" runat="server" />
            </h4>
            <p>
                <em>Starts:</em>
                <span class="right-info"><sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("MMM dd, yyyy") %>' /> @ <sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# ((DateTime)Eval("EventStart")).ToLocalTime().ToString("h:mm tt") %>' /></span>
            </p>
            <sf:ContentBrowseAndEditToolbar ID="BrowseAndEditToolbar" runat="server" Mode="Edit,Delete,Unpublish"></sf:ContentBrowseAndEditToolbar>
        </li>
    </ItemTemplate>
</telerik:RadListView>
<sf:Pager id="pager" runat="server"></sf:Pager>

This thread is closed