Hi!
I have a RadDatePicker that I want to reset its value on the server-side during a postback when the input is invalid. But it seems that once the property InvalidTextBoxValue is set, there is no way to clear that.
My test code looks something like this:
I studied the source code in RadDateInput.cs and there are two variables used by InvalidTextBoxValue:
It seems that those variables are never cleared anywhere, and once they are set there is no way to reset them, and those variables are affecting the logic of several properties and functions.
Shouldn't these variables be cleared when calling RadDatePicker.Clear or when setting RadDatePicker.SelectedDate, so that the RadDatePicker starts to behave "normally" again? Otherwise the RadDatePicker remains locked in its "invalid state" no matter what.
As an example, the following property of RadDateInput will never work properly again once the invalidDateStringFlag was set, since that flag is never cleared:
Setting a new value for the SelectedDate will not change anything -- the returned value will always be Null in that state, no matter what it is changed server-side on the RadDatePicker!
I am using version Telerik.Web.UI.dll 2010.3.1109.35
So, the final question is how to put a new valid value into a RadDatePicker after the user has entered an invalid value? This should preferably be done server-side, since there are some other actions too that need to be taken following an invalid date input (not just resetting the date picker).
I have a RadDatePicker that I want to reset its value on the server-side during a postback when the input is invalid. But it seems that once the property InvalidTextBoxValue is set, there is no way to clear that.
My test code looks something like this:
If
Page.IsPostBack
AndAlso
Not
String
.IsNullOrEmpty(
Me
.RadDatePicker1.InvalidTextBoxValue)
Then
' None of the following will help to show a new selected date in the date input -- the date input will fail to show anything
Me
.RadDatePicker1.Clear()
Me
.RadDatePicker1.SelectedDate = Now.
Date
Me
.RadDatePicker1.DateInput.Clear()
Me
.RadDatePicker1.DateInput.SelectedDate = Now.
Date
End
If
I studied the source code in RadDateInput.cs and there are two variables used by InvalidTextBoxValue:
protected
bool
invalidDateStringFlag =
false
;
protected
string
invalidDateString;
It seems that those variables are never cleared anywhere, and once they are set there is no way to reset them, and those variables are affecting the logic of several properties and functions.
Shouldn't these variables be cleared when calling RadDatePicker.Clear or when setting RadDatePicker.SelectedDate, so that the RadDatePicker starts to behave "normally" again? Otherwise the RadDatePicker remains locked in its "invalid state" no matter what.
As an example, the following property of RadDateInput will never work properly again once the invalidDateStringFlag was set, since that flag is never cleared:
public
virtual
DateTime? SelectedDate
{
get
{
if
(String.IsNullOrEmpty(Text) || invalidDateStringFlag)
{
return
null
;
}
else
{
return
DateTime.ParseExact(Text, hiddenFormat, DateTimeFormatInfo.InvariantInfo);
}
}
set
{
if
(value.HasValue)
{
if
((value > MaxDate) || (value < MinDate))
{
throw
new
ArgumentOutOfRangeException(
"SelectedDate"
, String.Format(
"Value of '{0}' is not valid for 'SelectedDate'. 'SelectedDate' should be between 'MinDate' and 'MaxDate'."
, value));
}
Text = value.Value.ToString(hiddenFormat, DateTimeFormatInfo.InvariantInfo);
}
else
{
Text =
null
;
}
}
}
Setting a new value for the SelectedDate will not change anything -- the returned value will always be Null in that state, no matter what it is changed server-side on the RadDatePicker!
I am using version Telerik.Web.UI.dll 2010.3.1109.35
So, the final question is how to put a new valid value into a RadDatePicker after the user has entered an invalid value? This should preferably be done server-side, since there are some other actions too that need to be taken following an invalid date input (not just resetting the date picker).