M
Mark
Hi,
I had a datetimepicker server control that worked great in 1.x but I am
having trouble with it in ASP.NET 2.x For some reason, the ViewState value
is always null on postback so IPostBackDataHandler.LoadPostData is unable to
access the properties correctly. Is there a change I should make? Here's
the iPostBackHandler code:
void IPostBackDataHandler.RaisePostDataChangedEvent() {
//OnSelectedIndexChanged(System.EventArgs.Empty);
OnDateChanged(System.EventArgs.Empty);
}
bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection) {
// when it access the SelectedDate here, its ViewState value is null
DateTime PreviousSelectedDate = SelectedDate;
DateTime DateSubmitted = SelectedDate;
// other code
}
The code for the SelectedDate property is
[
Description("Gets or sets the date for the DateTimePicker control."),
Category("Appearance"),
//DefaultValue(),
Bindable(true),
]
public virtual DateTime SelectedDate
{
get
{
object savedSelectedDate;
savedSelectedDate = this.ViewState["SelectedDate"];
if (savedSelectedDate != null)
return (DateTime) savedSelectedDate;
return DateTimeNotSet;
}
set
{
this.ViewState["SelectedDate"] = value;
}
}
I've checked and EnabledViewState is not set to false on the page or
controls. Any suggestions?
I had a datetimepicker server control that worked great in 1.x but I am
having trouble with it in ASP.NET 2.x For some reason, the ViewState value
is always null on postback so IPostBackDataHandler.LoadPostData is unable to
access the properties correctly. Is there a change I should make? Here's
the iPostBackHandler code:
void IPostBackDataHandler.RaisePostDataChangedEvent() {
//OnSelectedIndexChanged(System.EventArgs.Empty);
OnDateChanged(System.EventArgs.Empty);
}
bool IPostBackDataHandler.LoadPostData(string postDataKey,
System.Collections.Specialized.NameValueCollection postCollection) {
// when it access the SelectedDate here, its ViewState value is null
DateTime PreviousSelectedDate = SelectedDate;
DateTime DateSubmitted = SelectedDate;
// other code
}
The code for the SelectedDate property is
[
Description("Gets or sets the date for the DateTimePicker control."),
Category("Appearance"),
//DefaultValue(),
Bindable(true),
]
public virtual DateTime SelectedDate
{
get
{
object savedSelectedDate;
savedSelectedDate = this.ViewState["SelectedDate"];
if (savedSelectedDate != null)
return (DateTime) savedSelectedDate;
return DateTimeNotSet;
}
set
{
this.ViewState["SelectedDate"] = value;
}
}
I've checked and EnabledViewState is not set to false on the page or
controls. Any suggestions?