Hello,
I am using ASP.NET 3.5 with C#, telerik version 2012.1.515.35.
I have a RadTimepicker inside an UserControl.
I want to restrict entering of future time. Suppose I have 7:00 AM on my computer then user can select / insert maximum time 7:00 am, not more than that.
I also I need to show the RadTimepicker's time as per logged-in user's timezone. For that I am taking DateTime.UTCNow and converting it to user's time with some extension method.
The ascx page's RadTimepicker control's configuration is :
And in Page_PreRender() event of UserControl i call following method to set the RadTimePicker's property :
The extension method to convert time is as below :
FYI : My computer's timezone is "(UTC+5:30) Chennai, Kolkata, Mumbai, New Delhi".
Set your PC's time between 8:30 AM to 10:30 AM, and run the project. The time-view will show you time upto 23:00 hours with 1 hour interval, but selection of any time will give you the error icon i.e. invalid time inside RadTimePicker.
You have any idea why it is happening?
Thanks..
I am using ASP.NET 3.5 with C#, telerik version 2012.1.515.35.
I have a RadTimepicker inside an UserControl.
I want to restrict entering of future time. Suppose I have 7:00 AM on my computer then user can select / insert maximum time 7:00 am, not more than that.
I also I need to show the RadTimepicker's time as per logged-in user's timezone. For that I am taking DateTime.UTCNow and converting it to user's time with some extension method.
The ascx page's RadTimepicker control's configuration is :
<
telerik:RadTimePicker
ID
=
"rtpVitals"
runat
=
"server"
Width
=
"85"
DateInput-DateFormat
=
"HH:mm"
TimeView-TimeFormat
=
"HH:mm"
Skin
=
"Hay"
>
<
Calendar
UseRowHeadersAsSelectors
=
"False"
UseColumnHeadersAsSelectors
=
"False"
ViewSelectorText
=
"x"
>
</
Calendar
>
<
TimeView
CellSpacing
=
"-1"
TimeFormat
=
"HH:mm"
OnClientTimeSelected
=
"OnClientTimeSelected"
>
</
TimeView
>
<
TimePopupButton
CssClass
=
""
ImageUrl
=
""
HoverImageUrl
=
""
onblur
=
"hideTimePopup('rtpVitals');"
>
</
TimePopupButton
>
<
DatePopupButton
Visible
=
"False"
CssClass
=
""
ImageUrl
=
""
HoverImageUrl
=
""
></
DatePopupButton
>
<
DateInput
CssClass
=
"txtbox txtBack-Color"
BorderColor
=
"#D0D1AE"
BorderStyle
=
"Solid"
BorderWidth
=
"1"
ForeColor
=
"#333333"
onblur
=
"enterDateTime();"
>
</
DateInput
>
</
telerik:RadTimePicker
>
And in Page_PreRender() event of UserControl i call following method to set the RadTimePicker's property :
private
void
setTimePicker()
{
try
{
TimeZoneInfo t = TimeZoneInfo.FindSystemTimeZoneById(
"Central Standard Time"
);
DateTime d = DateTime.UtcNow.ToUserTime(t);
rtpVitals.TimeView.StartTime =
new
TimeSpan(0, 0, 0);
if
(d.Hour < 1)
{
rtpVitals.TimeView.Interval =
new
TimeSpan(0, d.Minute/2, 0);
if
(d.Minute <= 1)
{
rtpVitals.TimeView.Interval =
new
TimeSpan(0, 0, d.Second/2);
}
}
else
if
(d.Hour < 12)
{
rtpVitals.TimeView.Interval =
new
TimeSpan(0, 30, 0);
}
else
{
rtpVitals.TimeView.Interval =
new
TimeSpan(1, 00, 0);
}
rtpVitals.TimeView.EndTime =
new
TimeSpan(d.Hour, d.Minute, d.Second);
}
catch
(Exception ex)
{
throw
ex;
}
}
The extension method to convert time is as below :
public
static
DateTime ToUserTime(
this
DateTime utcTime, TimeZoneInfo toUserTimeZone)
{
try
{
utcTime = DateTime.SpecifyKind(utcTime, DateTimeKind.Unspecified);
//Create the userTime object
//Set it to UTC time by default. It would be changed later
DateTime userTime = utcTime;
//Convert the time
TimeZoneInfo fromTimeZone = TimeZoneInfo.Utc;
userTime = TimeZoneInfo.ConvertTime(utcTime, fromTimeZone, toUserTimeZone);
//Return the TimeZone
return
userTime;
}
catch
{
throw
;
}
}
FYI : My computer's timezone is "(UTC+5:30) Chennai, Kolkata, Mumbai, New Delhi".
Set your PC's time between 8:30 AM to 10:30 AM, and run the project. The time-view will show you time upto 23:00 hours with 1 hour interval, but selection of any time will give you the error icon i.e. invalid time inside RadTimePicker.
You have any idea why it is happening?
Thanks..