ASP.NET Ajax CalendarExtender will not update SelectedDate value

无人久伴 提交于 2019-12-05 02:51:58

After searching the Internet countless times, there doesn't appear to be a fix for this problem. A solution (if you want to call it that) could be to manually assign SelectedDate using conversion from the textbox (this requires you to set the format in the markup, though):

if(IsPostBack) {
blahCalendarExtender.SelectedDate = DateTime.ParseExact(blah.Text, blahCalendarExtender.Format, null);
// do postback actions
} else {
// for instance, maybe initalize blahCalendarExtender to today
blahCalendarExtender.SelectedDate = DateTime.Today;
}

(Where blah is the Text Control and blahCalendarExtender is the extender extending blah)

It seems that the calendarExtender control should be intelligent enough to do this on its own though.

Make sure to put the texbox and extender in an UpdatePanel (I don't see this in the code you provided).

I have found a very strange solution for this.

Do not initialize the value for the textbox which has calendar extender attached. Keep the textbox blank.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!