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

Forums / Developing with Sitefinity / Removing Date from Events Module

Removing Date from Events Module

6 posts, 0 answered
  1. Chad
    Chad avatar
    19 posts
    Registered:
    11 Sep 2008
    25 Nov 2009
    Link to this post
    Hello Again,

    I'm trying to remove the Event End Date field from the EventsItemEdit control.  I've already gone through the process of applying the override in the ControlsConfig XML, and have the EventsItemEdit.ascx and EventsItemEdit.ascx.resx in the appropriate places.  Also, in the web.config, I commented out the following line thinking it might help:

    <add key="Events.Event_End" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Now"/>

    I'm able to view the page in edit view (and the Event End date is not displayed as expected).  However, when I click "Save Changes", the attached error occurs when trying to save the event.  Presumably, because the code behind is looking for the Event End Date input box, but it doesn't find it. 

    What else do I need to edit/remove to get this working? 

    Thank you.

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    25 Nov 2009
    Link to this post
    Hi Chad,

    Instead of removing the controls responsible for showing Event_End in EventsItemEdit template you can hide them with div. Sample is shown below:

         <div  style="display:none;">
            <asp:Label ID="lblEventEnd" runat="server" Text='<%$Resources:EventEnd %>'
             AssociatedControlID="Event_End"></asp:Label>
             <telerik:RadDateTimePicker id="Event_End" runat="server">
               </telerik:RadDateTimePicker>
             <asp:RequiredFieldValidator runat="server" ID="validator2" ControlToValidate="Event_End" ErrorMessage="<%$Resources:EnterDate %>"></asp:RequiredFieldValidator>
                                     
     <p class="example">
    <asp:Literal ID="ltrEventEnd" runat="server" Text="<%$Resources:EventEndNote %>" /></p>
     </div>

    Note that this will hide the control, but not remove the value.  Unfortunately there is a small bug in SaveConent method that allows you to remove the control but then we check the entered value. So my suggestion is just hiding the control. I hope that this will do the trick.

    Let us know how it goes.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Chad
    Chad avatar
    19 posts
    Registered:
    11 Sep 2008
    30 Nov 2009
    Link to this post
    Thank you for your reply Ivan, but the problem with just hiding the field is that the validation that compares the end date to the start date still fires.  As a result, I get the error that "Event start should be earlier than Event end".  I get this because I set the Event start to some future date, but by default, Event end is the current date (plus 1 hour). 

    Can that validation be shut off somewhere?  I don't see a custom validator on the control, so the validation must be done in the SaveContent method.

    Thank you.

    Chad
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    30 Nov 2009
    Link to this post
    Hello Chad,

    The problem is that Event_Start and Event_End have to be required fields. We made this for the forthcoming SP2. The problem is that the values are checked and persisted in SaveContent() method of EventsItemEdit view. A solution for your case will require to create a custom view and replace the default EventsItemEdit. In your custom view you have to inherit from ContentItemEdit<EventsItemsView> and remove the EventsEnd control and override SaveContent method where just call base.SaveContent() .

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  5. Chad
    Chad avatar
    19 posts
    Registered:
    11 Sep 2008
    02 Dec 2009
    Link to this post
    Thanks Ivan.  One more question.  Rather than doing the override of the control, a solution that would suit my needs is to just make the Event End Date/Time default to the MAX date (like the Expiration Date does) on the Create New Event page.  I thought for sure this would be as simple as changing the "defaultValue" to "#MAX" for this key in the web.config:

    <add key="Events.Event_End" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Max"/>
                   
    But alas, it doesn't appear to be that easy for it still defaults to the current date plus 1 hour.  I don't suppose there is a way to change the default value without doing the override, is there?

    Thank you for all your help.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    02 Dec 2009
    Link to this post
    Hello Chad,

    In the EventsItemEdit template you can find RadDateTimePicker with ID= "Event_End" and set SelectedDate

    RadDateTimePicker1.SelectedDate = DateTime.MaxValue

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
6 posts, 0 answered