日期:2014-05-20  浏览次数:20781 次

请教一下,怎么确定Textbox里面的日期是三天内的?
前提:Textbox里面的时期已经为2009-07-24这样的格式.
我想用 customvalidator控件验证 日期是否在规定的范围内 。
规定的范围是从今天起到未来三天,也就是2009-07-24~2009-7~27(包括24和27号)。
求高人..



------解决方案--------------------
DateTime oldDate = new DateTime(2009,7,27);
DateTime newDate = DateTime.Now;
TimeSpan ts = newDate - oldDate;
int differenceInDays = ts.Days;
this.Response.Write(differenceInDays.ToString());
------解决方案--------------------
今天是2009-7-24,则2009-7-27是:
DateTime dt1 = DateTime.Today.AddDays(3);