Calendar Extendar is not showing Starting Date of one textbox to selected date of another textbox

浪子不回头ぞ 提交于 2019-12-04 06:35:35

问题


I'll try to simplify my query as much as possible. I am using to textboxes one is for starting date and one is for ending date. starting date is working well but in ending date it's start date should be selected date of starting date textbox.

Here is my Code.

protected void txtSRPStartDate_TextChanged(object sender, EventArgs e)
{
    txtSRPEndingDate_CalendarExtender.StartDate = Convert.ToDateTime(txtSRPStartDate_CalendarExtender.SelectedDate);
    txtSRPEndingDate_CalendarExtender.EndDate = DateTime.Now;
}

In this code when i'd debugged the code it's showing me selected date of starting date textbox as null.

Any Suggestion please.


回答1:


Quote from the first link in a google search.

The SelectedDate of the CalendarExtender is just to set an initial selected date on the calendar.

You can't use is to get the last selected date by the user. The selectedDate property isn't updated to the date the user selects!!

So instead, you need to get the date from the textbox not the calendar extender.

protected void txtSRPStartDate_TextChanged(object sender, EventArgs e)
{
    txtSRPEndingDate_CalendarExtender.StartDate = Convert.ToDateTime(txtSRPStartDate.Text);
    txtSRPEndingDate_CalendarExtender.EndDate = DateTime.Now;
}


来源:https://stackoverflow.com/questions/23029512/calendar-extendar-is-not-showing-starting-date-of-one-textbox-to-selected-date-o

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