More in this section

Forums / Developing with Sitefinity / DateTime MetaField default

DateTime MetaField default

5 posts, 0 answered
  1. KMac
    KMac avatar
    133 posts
    Registered:
    15 Dec 2008
    14 May 2009
    Link to this post
    Hello,

    Is there an easy way to have a datetime field default to a blank field when creating new items. I've added a datetime field to a custom NewsItemnew.ascx. In the web.config I can add:

    #Now
    #Max
    or leave blank for the defaultValue in the following:

    <add key="News.Custom_Date" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue="#Max"/> 

    I was hoping to just leave the DefaultValue blank so the field would be empty but instead it has 01/01/0001 in the radDateTimePicker. I just want it to be empty since the date is optional.

    Is there something I'm missing?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 May 2009
    Link to this post
    Hello Kalvin MacLeod,

    It is not possible to have nothing for the Publication_Date textbox. You should remove the value manually. In our code we set the default value programmatically, which does not allow you to manage it through web.condfig property.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    15 May 2009
    Link to this post
    Hello Kalvin MacLeod,

    As a option you can create a new metakey

    <add key="News.Publication_Date1" valueType="DateTime" visible="True" searchable="True" sortable="True" defaultValue=""/> 

    and add new matafield in NewsItemNew and NewItemEdit templates.

    <li> 
    <asp:Label ID="Label9" AssociatedControlID="Publication_Date1" runat="server"
                            <asp:Literal ID="Literal19" runat="server" Text="Publication_Date1"
                            </asp:Literal> <em id="Publication_DateLabel1" runat="server"></em></asp:Label>                                     
     <telerik:RadDateTimePicker ID="Publication_Date1" runat="server"
    </telerik:RadDateTimePicker> 
    </li> 

    You can comment the default RadDateTimePicker with  ID="Publication_Date" and use your custom one instead. You can follow the same approach for Expiration_Date field.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  4. Eliza Sahoo
    Eliza Sahoo avatar
    5 posts
    Registered:
    25 Jan 2010
    08 Feb 2010
    Link to this post

    RadDateTimePicker control displays 12 AM as default time. If you want to change this default time following can help you out.

    <telerik:RadDateTimePicker ID="RadDate" Runat="server" Skin="WebBlue" >
    <TimePopupButton HoverImageUrl="" ImageUrl="" />
    <ClientEvents OnDateSelected="DateSelected" />
    <TimeView CellSpacing="-1" StartTime="07:00" EndTime="23:00" Interval="0:15:0" Columns="6" OnClientTimeSelected="ClientTimeSelected"></TimeView>
    <Calendar skin="WebBlue" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
    <DatePopupButton HoverImageUrl="" ImageUrl="" />
    </telerik:RadDateTimePicker>

    thanks'
  5. Eliza Sahoo
    Eliza Sahoo avatar
    5 posts
    Registered:
    25 Jan 2010
    23 Mar 2010
    Link to this post

    RadDateTimePicker control displays 12 AM as default time. If you want to change this default time following can help you out.

    <telerik:RadDateTimePicker ID="RadDate" Runat="server" Skin="WebBlue" >
    <TimePopupButton HoverImageUrl="" ImageUrl="" />
    <ClientEvents OnDateSelected="DateSelected" />
    <TimeView CellSpacing="-1" StartTime="07:00" EndTime="23:00" Interval="0:15:0" Columns="6" OnClientTimeSelected="ClientTimeSelected"></TimeView>
    <Calendar skin="WebBlue" UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"></Calendar>
    <DatePopupButton HoverImageUrl="" ImageUrl="" />
    </telerik:RadDateTimePicker>

    Hope u find this useful.
Register for webinar
5 posts, 0 answered