Asp.Net中的日期操作 [英] Date manipulation in Asp.Net

查看:76
本文介绍了Asp.Net中的日期操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个日期选择器代码。



我想要的是我只选择与星期一相关的日期。用户无法选择星期一以外的日期。



选择星期一日期后,还有其他6个文本框需要自动填写。



Ex。



17-11-2014(dd-mm-yyyy)由用户选择。

下一个文本框需要填写,如18,19,20 ... 2014年11月22日



如果您需要更多详细信息,请联系我。 onlybigb321@gmail.com



谢谢

解决方案

如果你想用ASP.NET做(服务器端)代码然后您可能想要查看DateTime实例的DateTime.DayOfWeek属性。



您要做的是发送用户选择的DateTime,在服务器端,检查该DateTime的日期为



  if (dateTime1.DayOfWeek == DayOfWeek.Monday){
// 是的dateTime是星期一
} else {
// 不,他选择任何其他日子
}





然后,您可以根据此数据填充剩余的控件。有关 MSDN上的DateTime.DayOfWeek 的更多信息[ ^ ]。


I want a date picker code.

What I want is that only dates related to Monday should me selected. A user cannot select dates other than Monday.

After the selection of Monday date there are other 6 textboxes that needs to be filled up auto.

Ex.

17-11-2014 (dd-mm-yyyy)is selected by the user.
The next text boxes need to be filled up like 18,19,20...22-11-2014

If you require more detail please contact me. onlybigb321@gmail.com

Thanks

解决方案

If you want to do it using ASP.NET (server-side) code then you might want to look at the DateTime.DayOfWeek property of the DateTime instance.

What you would do, is to send the DateTime that the user selected, and on the server side, check the Day for that DateTime as

if(dateTime1.DayOfWeek == DayOfWeek.Monday) {
   // yes the dateTime is monday
} else {
   // no, he selected any other day
}



You can then fill the remaining Controls by the data depending on this. More on DateTime.DayOfWeek here on MSDN[^].


这篇关于Asp.Net中的日期操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆