Welcome Guest Search | Active Topics | Sign In | Register

DatePicker default time Options
jeffs
Posted: Wednesday, March 19, 2008 8:50:10 AM
Rank: Newbie
Groups: Member

Joined: 3/19/2008
Posts: 2
Is there a way to change the default time when a date is selected on the calendar and the PickerFormat is set to MM/dd/yyyy hh:mm:ss tt? Right now it defaults to 12:00:00 AM but it would be nice to modify that on a per instance basis so the end user can have a reasonable default.
eo_support
Posted: Wednesday, March 19, 2008 9:03:44 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,083
Hi,

This is possible but requires some JavaScript programming. You would handle the date picker's ClientSideOnSelect event and change the value there:

Code: HTML/ASPX
<eo:DatePicker runat="server" id="DatePicker1" 
ClientSideOnSelect="on_select_handler" ...>
....
</eo:DatePicker>


Code: JavaScript
function on_select_handler()
{
    //Get the selected value
    var date = DatePicker1.getSelectedDate();

    //Create a new date value based on the
    //selected value and apply the default time
    var newDate = new Date(
        date.getFullYear(), date.getMonth(), date.getDate(),
        1, 2, 3);   //Default time: hour, minute and second

    //Change the date picker's value
    DatePicker1.setSelectedDate(newDate);
}


Thanks
jeffs
Posted: Wednesday, March 19, 2008 9:57:46 AM
Rank: Newbie
Groups: Member

Joined: 3/19/2008
Posts: 2
Worked great. Thanks for the quick reply.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.