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

Forums / Designing & Styling / Date format

Date format

32 posts, 0 answered
  1. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    12 Oct 2012
    17 May 2011
    Link to this post
    How do I format the event date and time to say (for example):

    June 5, 2011 1:00 pm

    <sf:FieldListView ID="EventStart" runat="server" Format="{EventStart.ToLocal():MMM dd, yyyy HH:mm}" runat="server" />

    Also, is there a way to get a custom field to show using the sf:FieldListView control.  For example, I added a custom field called "Cost" and I'd like it to show in the template along with dates, address, contact, etc.
  2. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    18 May 2011
    Link to this post
    Hi Amanda Shafer,

    If you want to implement 12h time format with AM/PM designation please use the below sample.

    <sf:FieldListView ID="EventStart" runat="server" Format=" | {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
    Concerning using your custom field in a template, please try including it like this:
    <sitefinity:TextField runat="server" DisplayMode="Read" Value='<%# Eval("Cost")%>' />
    I hope this information helps, if you have any further questions, please let us know.
    Greetings,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    12 Oct 2012
    19 May 2011
    Link to this post
    Thank you, Boyan.

    Next question is whether anyone has been able to do the following. We have a mix of events that occur on one day and those that last two or three. I'm trying to find a good way to get the dates to format to make this clear.

    I could do a field for start date and one for end date, but then when the event is on one day it is redundant.  But I can't just use the start date because some last more than one day.

    I tried adding an event with no end date, but then it doesn't display on my list at all.

    I'd to have a way to say Date: June 10, 2011   for single day events and  Date: June 10 - 15, 2011 for multiple dates.

    Has anyone acheived something similiar to this?

  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    26 May 2011
    Link to this post
    Hi Amanda Shafer,

    The functionality you demand is implemented in the default template we're using for Events - if it's a one day Event we're displaying only that date (e.g. Dates: 26 May, 2011) if it's a several day Event we're displaying EventStart and EventEnd dates (e.g. Dates: 25 – 25 May, 2011). Please refer to the attached screenshot for more information. I'm pasting the default template below as well:

    <%@ 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="sfeventsList sfeventsListTitleCityDate">
                <asp:PlaceHolder ID="ItemsContainer" runat="server" />
            </ul>
        </LayoutTemplate>
        <ItemTemplate>
            <li class="sfeventListItem">
                <h2 class="sfeventTitle">
                    <sf:DetailsViewHyperLink TextDataField="Title" ToolTipDataField="Description" runat="server" />
                </h2>
                <div class="sfeventMetaInfo">
                    <sf:FieldListView ID="where" runat="server"
                        Text="{0} | " Properties="City"   />
                    <sf:FieldListView ID="EventsDates" runat="server" />
                    <sf:CommentsBox ID="itemCommentsLink" runat="server" CssClass="sfeventCommentsCount"/>
                </div>
                <sf:ContentBrowseAndEditToolbar ID="BrowseAndEditToolbar" runat="server" Mode="Edit,Delete,Unpublish"></sf:ContentBrowseAndEditToolbar>
            </li>
        </ItemTemplate>
    </telerik:RadListView>
    <sf:Pager id="pager" runat="server"></sf:Pager>
    I hope this information helps you achieve the desired functionality. If you have any further question, please do not hesitate to ask.

    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    12 Oct 2012
    26 May 2011
    Link to this post
    Hi Boyan,
    Thank you! How do I format it so that it's as follows: March 11 - 12, 2010 as opposed to day, month, year?  I tried
    {EventStart.ToLocal():MMM dd, yyyy}  but that doesn't seem to have any effect.
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    26 May 2011
    Link to this post
    Hi Amanda Shafer,

    Thank you for getting back to me. Let's just clarify one thing, so that I'm sure we're on the same track here - the end result that you want to be displayed on the frontend page should be:
    1) One day events: ''Dates: 26 May, 2011"
    2) Multiple days events: "Dates: 25 – 27 May, 2011"
    or you'll also need to display the hours as well?
    The reason why I'm asking you this question, is that if you won't need to display the hours at all, you can simply leave the EventEnd field empty, which will display single date for single days events, and Start-End dates for multiple days events using :
    <sf:FieldListView ID="EventsDates" runat="server" />
    If you need to display the hours as well, then you'll have to use
    <sf:FieldListView ID="EventStart" runat="server" Format="  {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
     <sf:FieldListView ID="EventEnd" runat="server" Format=" - {EventEnd.ToLocal():dd, yyyy hh:mm tt}" />
    Please let me know if the suggested solutions differ from what you desire to achieve as end functionality, so that I can advise you further.

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    12 Oct 2012
    27 May 2011
    Link to this post
    Hello Boyan,

    The hours are not important. However, I do need it to format with Month, Day, Year. The default you provided is Day Month Year.

    When I leave the end date empty, the event does not appear at all on the page.

    Thanks!
  8. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    28 May 2011
    Link to this post
    Hi Amanda Shafer,

    Thank you for the clarification. The second option I've listed in my last response does set the format to MMM/DD/YYYY, you might use it in your template instead of the FieldLIstView control. I'm pasting below a refined version which does not display the extra "-" when the event is a single day event.

    <sf:FieldListView ID="EventStart" runat="server" Format="  {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
     <sf:FieldListView ID="EventEnd" runat="server" Format="  {EventEnd.ToLocal(): '\-' MMM dd, yyyy hh:mm tt}" />
    Please take a look at the attached screenshot as well, which shows how this change int he template affects the frontend rendering of Events. It displays both events that have to EventEnd date set, ones that end the same day (although I personally believe if the event will end the same day there'd be no need to fill in the End date; and a multiple days Event) If you have any further questions, please don't hesitate to ask. It was a pleasure for me to help you.

    Best wishes,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    08 Jun 2011
    Link to this post
    I am having issues with the single day event. If its a single day event, I only put in the event start date. When I remove the date from event end and save it, it puts the event start date back in the event end date field so my screen looks like

    sample event
    June 9  -  9 2011

    please advice.

    Thanks
  10. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    08 Jun 2011
    Link to this post
    Hello nana,

    Could it be that you're using an older version of Sitefinity, as I've tested this functionality with our latest release version and I was not able to reproduce the mentioned issues. If so, please let me know which build version you're using so I can inspect this issue further. Thanks in advance!

    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  11. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    08 Jun 2011
    Link to this post

    Standard Edition

    Build 4.0.1098.0

    License details

    Edition:
    Standard Edition


    And the required checkbox is not checked for enddate either.

    Thanks
    Nana
  12. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    09 Jun 2011
    Link to this post
    Hello nana,

    Thank you for the clarification. Indeed we have changed the logic for using EventStart and EventEnd dates, as I have just observed myself the date is automatically filled in the older version, so the template provided to Amanda would not work on your project as long as you do not upgrade to the newer version. However, please let me know of the use case scenario you want to implement, maybe we can come up with some workaround.

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  13. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    09 Jun 2011
    Link to this post
    Simply,
    there are events on single days and events on multiple days

    the events that are single days I want displayed as e.g. June 9 2011  and for multiple days it should be displayed as June 9  - 11 2011.

    I am using the widget templates. but as i said, the single day ones are displaying  June 9 - June 9 2011 because there is no way not to set the end date or leave blank
  14. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    10 Jun 2011
    Link to this post
    Hello nana,

    I'll try to come up with a sample that implements this functionality on your template, however I'd recommend you to consider upgrading your project to the newer version, not only will you benefit from getting the desired behavior out-of-the-box, but also you will get all the new functionality and fixes we've introduced. Please get back to me if you still prefer to use the current version, so I can try to provide you with some workaround.

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  15. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    10 Jun 2011
    Link to this post
    I tried to upgrade before and it was a terrible experience. My code and everythign else was totally screwed so I was thankful to have been able to revert back with 0 issues. Now I am comfortable with where I am and do not intend to upgrade since I am creating a mockup to show my clients. I have a deadline. I do not want anything to impact it. If you can provide me with a solution, I will appreciate it.
  16. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    16 Jun 2011
    Link to this post
    Hi nana,

    Thank you for the patience. I'm sorry to hear about the troubles you've had upgrading to Sitefinity 4.1, I'd still recommend you to do it so that you can benefit from all the features and bug fixes that we've implemented. If you experience any problems, please do not hesitate to contact us, we'll be glad to assist you.
    I have prepared a sample template that should suit your needs, however let me point out that the current issues you are experiencing are somehow related to several bugs that are fixed in 4.1. First, the EventEnd date is required in 4.0 and cannot be removed. If you remove it and save the event, EventEnd date is automatically added as EventStart + 10 years. This is also valid if you type in EventStart date  - the EventEnd is automatically set to EventStart+10years. I've made a sample template to you which handles these two issues , you might want to customize it a little bit to suit your needs. Please find attached the template files and a screenshot of the end result. You'll need to go to the Events widget on your page click on Edit->Advanced->ControlDefinition->Views->EvenFrontendList and set the app relative path to the template you've included in your project. You'll also need to delete the TemplateKey.
    Once again I want to note that this template cannot be a substitute to upgrading your project and benefiting from the fixes in the codebase. Also, setting this for your event widgets will require that you manually go and change the template of the widgets once you upgrade the project.


    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  17. Amanda Shafer
    Amanda Shafer avatar
    198 posts
    Registered:
    12 Oct 2012
    27 Jun 2011
    Link to this post
    Hi Boyan,
    I tried implementing the code you gave but get a message that there has been an error parsing the template. I will submit a support ticket.
  18. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    29 Jun 2011
    Link to this post
    Hi,

    I am not able to reproduce the template parsing error, can you, please, make sure you have followed the installation instruction properly? If you prefer, you can open a support ticket and attach a short video demonstrating the problems. Thanks in advance

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  19. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    20 Sep 2011
    Link to this post
    Hi Boyan, from what I have found after my upgrade to 4.2

    I can leave the event end date empty but it will not display on the website if I use this code

    <sf:FieldListView ID="EventStart" runat="server" Format="  {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
     <sf:FieldListView ID="EventEnd" runat="server" Format=" - {EventEnd.ToLocal():dd, yyyy hh:mm tt}" />

    The only way it displays if its a single day event is if I use

     

    <sf:FieldListView ID="EventsDates" runat="server" />

    However
    <sf:FieldListView ID="EventsDates" runat="server" />
     does not display it in the correct format i would like, which is June 9 2011

    What to do?




  20. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    21 Sep 2011
    Link to this post
    Hello Nana,

    Can you please clarify what you mean by "I can leave the event end date empty but it will not display on the website if I use this code"? Please find attached a short video demonstrating the usage of this sample code:
    <sf:FieldListView ID="EventStart" runat="server" Format="  {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
     <sf:FieldListView ID="EventEnd" runat="server" Format="  {EventEnd.ToLocal(): '\-' MMM dd, yyyy hh:mm tt}" />
    and the corresponding results, and please let me know if I've missed something.

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  21. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    21 Sep 2011
    Link to this post
    What I mean is.

    The option to just have a single day event is available so  I am able to just put a date in Event Start and then leave Event End blank.

    But when I leave Event End  field blank and use this code as given by Boyen, those single day events are not displayed on the website.

    <sf:FieldListView ID="EventStart" runat="server" Format="  {EventStart.ToLocal():MMM dd, yyyy hh:mm tt}" />
     <sf:FieldListView ID="EventEnd" runat="server" Format="  {EventEnd.ToLocal(): '\-' MMM dd, yyyy hh:mm tt}" />


    Its only when I use
    <sf:FieldListView ID="EventsDates" runat="server" />
    do they display on the website

    but I dont want to use that tag because I need correct formatting as Boyen gave

  22. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    22 Sep 2011
    Link to this post
    Hi Nana,

    I'm sorry if I have misunderstood your request, can you please specify the exact use case scenario that's needed. The sample code I've attached in my previous reply, and the video recorded demonstrate how to properly set up the template for events so it will display the dates in the desired format and leave the event end blank if it has no value entered.

    All the best,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  23. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    22 Sep 2011
    Link to this post

    hi boyen,
    it really is nothing more than what is there.

    I am using 4.2 with hotfixes

    I enter an event
    Start date 06-06-2012

    I leave end date fiedl blank because its a single day event and then save the event

    I modify widget template to use the code you provided for formatting date

    The event is not displayed on the website. Simple as that. The single date event is not displayed on the website but other events that have a start and end date are displayed.


    I remove the code you provided and then use the code below

    <sf:FieldListView ID="EventsDates" runat="server" /> and all events show including the single date event

    But I need to use your code because I need the dates formatted.

    Can this code below be formatted like the code you provided?

    <sf:FieldListView ID="EventsDates" runat="server" />

  24. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    23 Sep 2011
    Link to this post
    Hello Nana,

    I'm wondering, would there be a way to provide me with temporary login credentials for your site's backend? Generally there should be no problem with the code runnig on your side. Both EventStart and EventEnd dates are passed to the EventsDates FieldListView, what we're actually doing is call the control twice, and specify the desired format first for the EventStart, and then for the EventEnd date.

    Kind regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  25. Dan
    Dan avatar
    2 posts
    Registered:
    20 Sep 2010
    28 Sep 2011
    Link to this post
    Hi, Nana.

    I'm not sure where you left this but I had similar problems. I created the template as a user control as described elsewhere on the site. I had trouble when the end date was empty, and couldn't get the code to recognize it as null. If you think this might be similar, go here for the workaround:
    http://www.telerik.com/account/support-tickets/view-ticket.aspx?threadid=467622

    Dan
  26. nana
    nana avatar
    49 posts
    Registered:
    07 Sep 2010
    29 Sep 2011
    Link to this post

    Hi Boyan,
    Thanks for response. I am a development server so cannot provide you that information. I dont know why I am facing this problem.

     

    Hello Dan,

    Thanks for the response. For some reason, i cannot get to the thread. Can you please resend link?

    Thanks

     

     

    Nana

  27. Dan
    Dan avatar
    2 posts
    Registered:
    20 Sep 2010
    29 Sep 2011
    Link to this post
    Nana,

    Here was my user control that worked for me from that thread.

    Dan

    <%

     

    @ Control Language="C#" AutoEventWireup="true" CodeFile="EventsCustom1.ascx.cs"

     

     

     

    Inherits="SitefinityWebApp.Templates.EventsCustom1" %>

     

    <%

     

    @ 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" %>

     

     

    <

     

     

    script runat="server">

     

     

     

    protected void Events_OnItemDataBound(object sender, RadListViewItemEventArgs e)

     

    {

     

     

    if (e.Item is RadListViewDataItem)

     

    {

     

     

    RadListViewDataItem item = e.Item as RadListViewDataItem;

     

     

     

    Label lblDates = e.Item.FindControl("lblDates") as Label;

     

     

     

    DateTime eventStart = (item.DataItem as Telerik.Sitefinity.Events.Model.Event).EventStart.ToLocalTime();

     

     

     

    DateTime eventEnd = DateTime.Today;

     

     

     

    Boolean endDateEntered = false;

     

     

     

    try

     

    {

    eventEnd = (

     

    DateTime)(item.DataItem as Telerik.Sitefinity.Events.Model.Event).EventEnd;

     

    eventEnd = eventEnd.ToLocalTime();

    endDateEntered =

     

    true;

     

    }

     

     

    catch (Exception ex) { endDateEntered = false ; }

     

     

     

    if (!endDateEntered)

     

    {

     

     

    if (eventStart.ToString("h:mmtt") == "12:00AM") lblDates.Text += eventStart.ToString("dddd, MMM dd yyyy");

     

     

     

    else lblDates.Text += eventStart.ToString("dddd, MMM dd yyyy h:mmtt");

     

    }

     

     

    else

     

     

     

    if (eventStart.Date == eventEnd.Date)

     

     

     

    if (eventStart.TimeOfDay == eventEnd.TimeOfDay)

     

    {

    lblDates.Text += eventStart.ToString(

     

    "dddd, MMM dd yyyy h:mmtt");

     

    }

     

     

    else

     

    {

    lblDates.Text += eventStart.ToString(

     

    "dddd, MMM dd yyyy h:mmtt") + " to " + eventEnd.ToString("h:mmtt");

     

    }

     

     

    else

     

    {

     

     

    if (eventStart.ToString("h:mmtt") == "12:00AM") lblDates.Text += eventStart.ToString("dddd, MMM dd yyyy");

     

     

     

    else lblDates.Text += eventStart.ToString("dddd, MMM dd yyyy h:mmtt");

     

    lblDates.Text +=

     

    " to ";

     

     

     

    if (eventEnd.ToString("h:mmtt") == "12:00AM") lblDates.Text += eventEnd.ToString("dddd, MMM dd yyyy");

     

     

     

    else lblDates.Text += eventEnd.ToString("dddd, MMM dd yyyy h:mmtt");

     

    }

    }

    }

     

    </

     

     

    script>

     

    <

     

     

    telerik:RadListView ID="eventsList" ItemPlaceholderID="ItemsContainer" runat="server"

     

     

     

    EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false" OnItemDataBound="Events_OnItemDataBound">

     

     

     

    <LayoutTemplate>

     

     

     

    <sf:contentbrowseandedittoolbar id="MainBrowseAndEditToolbar" runat="server" mode="Add"></sf:contentbrowseandedittoolbar>

     

     

     

    <ul class="sfeventsList sfeventsListTitleCityDate">

     

     

     

    <asp:PlaceHolder ID="ItemsContainer" runat="server" />

     

     

     

    </ul>

     

     

     

    </LayoutTemplate>

     

     

     

    <ItemTemplate>

     

     

     

    <li class="sfeventListItem">

     

     

     

    <h2 class="sfeventTitle">

     

     

     

    <sf:detailsviewhyperlink id="DetailsViewHyperLink1" textdatafield="Title" tooltipdatafield="Description"

     

     

     

    runat="server" />

     

     

     

    </h2>

     

     

     

    <div class="sfeventMetaInfo">

     

     

     

    <asp:Label runat="server" ID="lblDates" CssClass="sfeventDateTime"></asp:Label><br />

     

     

     

    <sf:commentsbox id="itemCommentsLink" runat="server" cssclass="sfeventCommentsCount" />

     

     

     

    </div>

     

     

     

    <!-- <sf:contentbrowseandedittoolbar id="BrowseAndEditToolbar" runat="server" mode="Edit,Delete,Unpublish"></sf:contentbrowseandedittoolbar> -->

     

     

     

    </li>

     

     

     

    </ItemTemplate>

     

    </

     

     

    telerik:RadListView>

     

    <

     

     

    sf:pager id="pager" runat="server"></sf:pager>

     

  28. Stephanie
    Stephanie avatar
    19 posts
    Registered:
    16 Mar 2011
    17 Oct 2011
    Link to this post
    Hello,

    Is there a way to display just the times of an event using the templates of the the events widget?
    For example:  I just want 6:00 PM - 7:00 PM to show up for an event.


    Thanks,

    Steph
  29. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    30 Nov 2016
    18 Oct 2011
    Link to this post
    Hi Stephanie,

    Sure, you can modify the default template and specify the format which will be taken into account when representing the events dates, for example:
    <sf:FieldListView ID="EventStart" runat="server" Format="{EventStart.ToLocal(): hh:mm tt}"/>
    <sf:FieldListView ID="EventEnd" runat="server" Format="{EventEnd.ToLocal(): '\-' hh:mm tt}"/>
    Please not that for events with just EventStart specified it will display just that time. I'm pasting below the complete template:
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="DetailsViewCustom.ascx.cs" Inherits="SitefinityWebApp.DetailsViewCustom" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.ContentUI" Assembly="Telerik.Sitefinity" %>
    <%@ Register TagPrefix="sf" Namespace="Telerik.Sitefinity.Web.UI.PublicControls.BrowseAndEdit" Assembly="Telerik.Sitefinity" %>
    <%@ Import Namespace="Telerik.Sitefinity" %>   
     
    <telerik:RadListView ID="SingleItemContainer" ItemPlaceholderID="ItemContainer" AllowPaging="False" runat="server" EnableEmbeddedSkins="false" EnableEmbeddedBaseStylesheet="false">
        <LayoutTemplate>
            <div class="sfeventDetails">
                <div class="sfeventLinksWrp">
                    <sf:MasterViewHyperLink ID="MasterViewHyperLink1" class="sfeventBack" Text="<%$ Resources:EventsResources, AllEvents %>" runat="server" />
                </div>
                <asp:PlaceHolder ID="ItemContainer" runat="server" />
            </div>
        </LayoutTemplate>
        <ItemTemplate>
            <h1 class="sfeventTitle">
                <asp:Literal ID="Literal1" Text='<%# Eval("Title") %>' runat="server" />
            </h1>
            <sf:ContentBrowseAndEditToolbar ID="BrowseAndEditToolbar" runat="server" Mode="Edit,Delete,Unpublish"></sf:ContentBrowseAndEditToolbar>
            <ul class="sfeventDatesLocationContacts">
              <sf:FieldListView ID="EventStart" runat="server" Format="{EventStart.ToLocal(): hh:mm tt}"/>
              <sf:FieldListView ID="EventEnd" runat="server" Format="{EventEnd.ToLocal(): '\-' hh:mm tt}"/>
     
                <sf:FieldListView ID="Location" runat="server"
                    Text="<%$ Resources:EventsResources, Where %>" Properties="City, State, Country"
                    WrapperTagName="li"
                />
                <sf:FieldListView ID="Street" runat="server"
                    Text="<%$ Resources:EventsResources, Address %>" Properties="Street"
                    WrapperTagName="li"
                />
                <sf:FieldListView ID="ContactName" runat="server"
                    Text="<%$ Resources:EventsResources, ContactName %>" Properties="ContactName"
                    WrapperTagName="li"
                />
                <sf:FieldListView ID="ContactEmail" runat="server"
                    Text="<%$ Resources:EventsResources, ContactEmail %>" Properties="ContactEmail"
                    WrapperTagName="li"
                />
                <sf:FieldListView ID="Web" runat="server"
                    Text="<%$ Resources:EventsResources, WebSite %>" Properties="ContactWeb"
                    WrapperTagName="li"
                />
                <sf:FieldListView ID="Phone" runat="server"
                    Text="<%$ Resources:EventsResources, ContactPhone %>" Properties="ContactPhone, ContactCell"
                    WrapperTagName="li"
                />
            </ul>
            <%--<div class="sfgcAuthor">
                <asp:Literal ID="Literal2" Text="<%$ Resources:Labels, By %>" runat="server" />
                <sf:PersonProfileView runat="server" /> | <asp:Literal ID="Literal3" Text='<%# Eval("PublicationDate", "{0:dd MMM, yyyy}") %>' runat="server" />
            </div>--%>
            <div class="sfeventContent">
                <asp:Literal ID="Literal4" Text='<%# Eval("Content") %>' runat="server" />
            </div>
            <sf:ContentView
                 id="commentsListView"
                 ControlDefinitionName="EventsCommentsFrontend"
                 DetailViewName="CommentsMasterView"
                 ContentViewDisplayMode="Master"
                 runat="server" />
            <sf:ContentView
                 id="commentsDetailsView"
                 ControlDefinitionName="EventsCommentsFrontend"
                 DetailViewName="CommentsDetailsView"
                 ContentViewDisplayMode="Detail"
                 runat="server" />
        </ItemTemplate>
    </telerik:RadListView>


    Regards,
    Boyan Barnev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  30. Josh Anderson
    Josh Anderson avatar
    48 posts
    Registered:
    15 Dec 2005
    10 Jan 2014
    Link to this post
    For whatever reason I wasn't able to get Dan's solution working on 6.x, and the logic to evaluate all-day events is overkill given the new option to explicitly set an event all-day. In case this helps anyone, here's the extension method I used:

    using System;
    using System.Web.UI;
     
    namespace SitefinityWebApp.widgets.helpers
    {
        public static class CommonTemplateExtensions
        {
            public static string GetEventDateText(this IDataItemContainer container, string propertyName)
            {
                var output = String.Empty;
     
                try
                {
                    var dataItem = container.DataItem as Telerik.Sitefinity.Events.Model.Event;
     
                    if (dataItem != null)
                    {
                        if (dataItem.AllDayEvent)
                        {
                            output = dataItem.EventStart.ToString("ddd, MMM dd, yyyy");
                             
                            if (dataItem.EventEnd.HasValue && dataItem.EventEnd.Value.Date != dataItem.EventStart.Date)
                            {
                                // This is a multi-day event
                                output += " to " + dataItem.EventEnd.Value.ToString("ddd, MMM dd, yyyy");
                            }
                        }
                        else
                        {
                            output = dataItem.EventStart.ToString("ddd, MMM dd, yyyy, h:mmtt");
     
                            if (dataItem.EventEnd.HasValue && dataItem.EventEnd.Value.Date != dataItem.EventStart.Date)
                            {
                                // This is a multi-day event
                                output += " to " + dataItem.EventEnd.Value.ToString("ddd, MMM dd, yyyy, h:mmtt");
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    output = "N/A";
                }
                return output;
            }
        }
    }

    If you want flexibility on format, you can modify to include arguments as needed. To use it, be sure to include the namespace for the class, then place this line in your item template for the event:

    <%# Container.GetEventDateText("") %>

    Hope this helps.
32 posts, 0 answered
1 2