Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Calendar > How to set date and time from codebehind in Page_Load event?

Not answered How to set date and time from codebehind in Page_Load event?

Feed from this thread
  • Posted on Jan 23, 2012 (permalink)

    Hello,

    I have a page that has two calendar controls on it. One is for indicating a start date / time and one is for indicating an end date / time. These values are ultimately saved in the database.

    When a user returns to their record and wishes to update these values, I'd like to show them what they were previously set to. I'm able to save and retrieve the date value by wiring up the SelectedDate.Value property. But this does not help me get the time.

    I'm also not sure how to set the time once I have the value from the server. I'm able to set the date but not the time.

    Please let me know how I'd go about setting the date AND time values in my Page_Load event.

    Many thanks in advance,

    ~ Dave

    Reply

  • jumpstart Master avatar

    Posted on Jan 24, 2012 (permalink)

    Dave:

    Would it be possible for you to post your form and code behind pages, and a screenshot of your form? This would make it easier to edit and update the application to produce the required functionality.

    Cheers!

    Reply

  • Posted on Jan 27, 2012 (permalink)

    Hello,

    Well, with the help of our support desk I was able to get this litte issue resolved. Turns out it was one of the 'self inflicted' issues... Here's a snippet of code that worked on a new test page.
    <telerik:RadDateTimePickerID="rdtIncFrom"runat="server">
        <DateInputDateFormat="dd/MM/yyyy hh:mm">
        </DateInput>
    </telerik:RadDateTimePicker>
    <asp:ButtonID="btn1"runat="server"Text="PostBack"/>
    <asp:LabelID="lbl1"runat="server"></asp:Label>
     
    protectedvoidPage_Load(objectsender, EventArgs e)
    {
        if(rdtIncFrom.SelectedDate != null)
            lbl1.Text = rdtIncFrom.SelectedDate.Value.ToString();
    }

    Once I saw the code work correctly I triple checked my Page_Load event and found that I was NOT checking for a null value before setting the new date/time.

    So, I'm sorry to bother everyone with this and I do very much appreciate the help and support I get from our Telerik Forums!

    I'll call this 'case closed' and lesson learned!

    ~ Dave

    Reply

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET AJAX > Calendar > How to set date and time from codebehind in Page_Load event?
Related resources for "How to set date and time from codebehind in Page_Load event?"

ASP.NET Calendar Features  |  Documentation  |  Demos  |  Telerik TV  |  Self-Paced Trainer  |  Step-by-step Tutorial  ]