Hi Daniel,
Here is the entire C# code of the control this snippet resides in.
using
System;
using
System.Data;
using
System.Configuration;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
using
Telerik.WebControls;
using
System.ComponentModel;
using
Fox.Fbc.Rds.RdsWeb.Data;
namespace
Fox.Fbc.Rds.RdsWeb.WebControls
{
/// <summary>
/// ValidTimeRangeValidator is used to check that start time and end time happen in chronological order
/// given the broadcasting day's start time of 6AM
/// </summary>
[ToolboxData(
"<{0}:ValidTimeRangeValidator runat=server ErrorMessage=\"End time should be past start time. Note that Broadcast Day starts at 6:00 AM. To select the whole day set both start and end times to 6:00 AM\"></{0}:ValidTimeRangeValidator>"
)]
public
class
ValidTimeRangeValidator : BaseValidator
{
public
static
readonly
TimeSpan BroadcastDayStart = TimeSpan.FromHours(6);
[TypeConverter(
typeof
(ValidatedControlConverter)), IDReferenceProperty, Themeable(
false
), DefaultValue(
""
)]
public
string
StartTimeControlID
{
get
{
object
obj2 =
this
.ViewState[
"StartTimeControlID"
];
if
(obj2 !=
null
)
{
return
(
string
)obj2;
}
return
string
.Empty;
}
set
{
this
.ViewState[
"StartTimeControlID"
] = value;
}
}
[TypeConverter(
typeof
(ValidatedControlConverter)), IDReferenceProperty, Themeable(
false
), DefaultValue(
""
)]
public
string
EndTimeControlID
{
get
{
object
obj2 =
this
.ViewState[
"EndTimeControlID"
];
if
(obj2 !=
null
)
{
return
(
string
)obj2;
}
return
string
.Empty;
}
set
{
this
.ViewState[
"EndTimeControlID"
] = value;
}
}
protected
override
bool
ControlPropertiesValid()
{
if
(String.IsNullOrEmpty(StartTimeControlID))
throw
new
HttpException(
"StartTimeControlID cannot be empty"
);
if
(String.IsNullOrEmpty(EndTimeControlID))
throw
new
HttpException(
"EndTimeControlID cannot be empty"
);
RadTimePicker startTime =
this
.NamingContainer.FindControl(StartTimeControlID)
as
RadTimePicker;
RadTimePicker endTime =
this
.NamingContainer.FindControl(EndTimeControlID)
as
RadTimePicker;
if
(startTime ==
null
)
throw
new
HttpException(String.Format(
"Validator control {0} cannot be found"
, StartTimeControlID));
if
(endTime ==
null
)
throw
new
HttpException(String.Format(
"Validator control {1} cannot be found"
, EndTimeControlID));
return
true
;
}
}
}
Thanks,
Olga