FORUMS

c360 Forums
 Home        Members    Calendar    Who's On

Welcome Guest ( Login | Register )
      



DatePicker and it's "pristine" returnValueExpand / Collapse
Message
Posted 6/19/2007 4:24:56 AMPost #1582
 

c360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expert
Consider the following IDatePicker code on a SavePage:

IDatePicker date = ControlFactory.CreateDatePicker();
date.ID = "datepicker";
date.DisplayStyle = DatePickerStyles.DateAndTime;
date.TimePickerInterval = TimePickerIntervals.FiveMinutes;
date.SelectedDate = new c360.Toolkit.CRM2005.CrmDateTime();
date.SelectedDate.Value = DateTime.Now.AddDays(1).ToString("s");

If the page gets generated on let's say 19-06-2007 on 10:13:37 (dutch format)
Then the picker shows, given the code above, 20-06-2007.
The time edit shows 10:10

If I do not change/edit anything then the returnvalue of the picker is given the code above is: 2007-06-20T10:13:37
I am expecting the returnvalue to be 2007-06-20T10:10:00 given the values on the SavePage showed to the user.

Is there an easy way to resolve this?

feature request: Given the sample above it would be nice if the time picker showed 10:15 when the page gets generated on 10:13:37...
Or 10:20 when TimePickerIntervals.TenMinutes is used...etc...
Or a property in the IDatePicker to turn such behavior on/off
Posted 9/6/2007 8:36:50 AMPost #1751
 

c360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expertc360 Product Expert
pklingens (6/19/2007)

If I do not change/edit anything then the returnvalue of the picker is given the code above is: 2007-06-20T10:13:37
I am expecting the returnvalue to be 2007-06-20T10:10:00 given the values on the SavePage showed to the user.

Is there an easy way to resolve this?

For all that might have the same issue, consider the following workarounds I found below:

In the protected void Page_Load(object sender, EventArgs e) method add:

Instance.RegisterClientScriptBlock("window.onload", "function window.onload() { fixDatePicker(); }");


In the javascript code do:

function fixDatePicker()
{
// datetime picker does not return the default selected value...if nothing is changed
var box = document.getElementById('datepickerTimePicker');
ChangeTimeHandler(box);
}

Where datepickerTimePicker is the ID of the time edit element that belongs to the IDateTimePicker with the given ID datepicker
ChangeTimeHandler is a method added to the page by c360 when adding a DateTimePicker on the page.
...
feature request: Given the sample above it would be nice if the time picker showed 10:15 when the page gets generated on 10:13:37...
Or 10:20 when TimePickerIntervals.TenMinutes is used...etc...
Or a property in the IDatePicker to turn such behavior on/off

This one is easily resolved, consider the following code:

IDatePicker date = ControlFactory.CreateDatePicker();
date.ID = "datepicker";
date.DisplayStyle = DatePickerStyles.DateAndTime;
date.TimePickerInterval = TimePickerIntervals.FiveMinutes;
date.SelectedDate = new c360.Toolkit.CRM2005.CrmDateTime();
date.SelectedDate.Value = DateTime.Now.AddDays(1).AddMinutes(4).ToString("s");

Just make sure the DateTimePicker rounds the time you set as SelectedDate to the nearest value given the interval, for FiveMinutes add 4 minutes to the time you set, TenMinutes add 9, etc...
(In the code above I want to get the time of the next day, so I also use AddDays(1)... )

Note: to get the right time (and not the AddMintes(x) one...) when the value is returned to your .Net code when the user does not change anything in the DateTimePicker you should use the fixdatepicker workaround above...
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: kanika.jackson, Ken Champion

PermissionsExpand / Collapse

All times are GMT -5:00, Time now is 6:21am

Powered by InstantForum.NET v4.1.4 © 2008
Execution: 0.953. 17 queries. Compression Enabled.