How to add or subtract dates in C# using ajax calendar extender?

你说的曾经没有我的故事 提交于 2019-12-20 07:42:16

问题


I have two textboxes in which I have used ajax calendar extender. When I choose a date from one of the text boxes, it should automatically fill the other textbox by adding some days or months.

How can I do that?


回答1:


Please follow this example and modify your code. Hope it helps.

<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
<cc2:CalendarPopup id="CalendarExtender1" runat="server" Width="71px" OnDateChanged="CalendarPopup1_DateChanged" AutoPostBack="True"></cc2:CalendarPopup>
<cc2:CalendarPopup id="CalendarExtender2" runat="server" Width="71px"></cc2:CalendarPopup>
</contenttemplate>
</asp:UpdatePanel>        

**Code behind:**

 protected void CalendarPopup1_DateChanged(object sender, EventArgs e)
    {
        CalendarPopup2.SelectedDate = CalendarPopup1.SelectedDate.AddDays(1); // you can add the number of days you want
    } 

Also the following link might give you better insight on this topic:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=149



来源:https://stackoverflow.com/questions/13006280/how-to-add-or-subtract-dates-in-c-sharp-using-ajax-calendar-extender

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