根据textbox1中用户选择的日期自动添加10个月到textbox2

时间:2013-12-20 06:32:13

标签: c# asp.net date

我有2个文本框。
在第一个文本框中,用户通过在asp.net中使用日历控件来选择日期。
在textbox1中添加所需日期后,我将不再添加10个月并自动在textbox2中显示日期。
在textbox1

中选择日期后,我可以使用哪个事件立即在textbox2中添加日期

例如:textbox1:19/12/2013 then after selecting this date, then textbox2 automatically fill with like textbox2:19/10/2014

请帮帮我

2 个答案:

答案 0 :(得分:0)

只需使用html5

 <input type="date">

简单明了

了解更多信息

http://www.w3.org/TR/html5-author/common-microsyntaxes.html#dates-and-times

答案 1 :(得分:0)

试试这个

DateTime add_Months = Convert.ToDateTime(textbox1.Text).AddMonths(10);
textbox2.Text = add_Months.ToString();