asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解

简介:

asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解决

string   temp="<table width=\"560\" cellpadding=\"0\" cellspacing=\"1\" bgcolor=\"dddddd\" align=center height=\"100\"> ";

temp=temp+"<tr align=\"center\" bgcolor=\"#CCCCCC\"> ";
temp=temp+"<td width =\"14%\" height=\"19\"> 日</td> ";
temp=temp+"<td width=\"14%\"> 一</td> ";
temp=temp+"<td width=\"14%\"> 二</td> ";
temp=temp+"<td width=\"14%\"> 三</td> ";
temp=temp+"<td width=\"14%\"> 四</td> ";
temp=temp+"<td width=\"14%\"> 五</td> ";
temp=temp+"<td width=\"14%\"> 六</td> ";
temp=temp+"</tr> ";
temp = temp + "<tr align=center bgcolor=ffffff height=19> ";

DateTime dt1 = System.Convert.ToDateTime("2009-7-2");
DateTime dt2 = System.Convert.ToDateTime("2009-8-20");
TimeSpan ts = dt2 -dt1 ;

int countday = (int)ts.TotalDays;

int maxi = countday;
int i=1 ;
while (dt1 < dt2)
{

    if (i == 1)
    {
        int t = xingqi(dt1.ToString("yyyy-MM-dd").ToString()); //开始的第一天位置
     
        while (i < t+1)
        {
            temp = temp + "<td align=center></td>";
            i++;
        }
    }

        temp = temp + "<td align=center>" + dt1.ToString("yyyy-MM-dd").ToString() + "</td>";


        if (i % 7 == 0)
                {
                    temp = temp + "</tr><tr align=center bgcolor=ffffff height=19>";
                }

                i = i + 1;

                dt1 = dt1.AddDays(1);


}

temp = temp + "</table>";


Response.Write(temp);
    }
    public static int xingqi(string d)      //判断星期几
    {
        int reslut = 0;  //周日
        string xq = Convert.ToDateTime(d).DayOfWeek.ToString();
        switch (xq)
        {
            case "Monday":   //星期一;
                reslut = 1;
                break;
            case "Tuesday":
                reslut = 2;
                break;
            case "Wednesday":
                reslut = 3;
                break;
            case "Thursday":
                reslut = 4;
                break;
            case "Friday":
                reslut = 5;
                break;
            case "Saturday":  //星期六;
                reslut = 6;
                break;
            case "Sunday":
                reslut = 0;
                break;
            default:
                reslut = 0;
                break;
        }
        return reslut;
    }
 asp.net(c#)两时间段每天是星期几,周几(时间段日历显示)的问题解决



本文转自左正博客园博客,原文链接:http://www.cnblogs.com/soundcode/archive/2011/07/20/2112040.html,如需转载请自行联系原作者

目录
相关文章
|
JavaScript .NET 开发框架
jquery + asp .net 日历 源码
  http://down.qiannao.com/space/file/meetrice/-6211-7684-6587-6863/-7f16-7a0b/demo.rar/.page
732 0
|
3月前
|
开发框架 前端开发 .NET
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
41 0
|
1月前
|
开发框架 前端开发 .NET
进入ASP .net mvc的世界
进入ASP .net mvc的世界
29 0
|
1月前
|
开发框架 前端开发 .NET
C# .NET面试系列六:ASP.NET MVC
<h2>ASP.NET MVC #### 1. MVC 中的 TempData\ViewBag\ViewData 区别? 在ASP.NET MVC中,TempData、ViewBag 和 ViewData 都是用于在控制器和视图之间传递数据的机制,但它们有一些区别。 <b>TempData:</b> 1、生命周期 ```c# TempData 的生命周期是短暂的,数据只在当前请求和下一次请求之间有效。一旦数据被读取,它就会被标记为已读,下一次请求时就会被清除。 ``` 2、用途 ```c# 主要用于在两个动作之间传递数据,例如在一个动作中设置 TempData,然后在重定向到另
95 5
|
8月前
|
存储 开发框架 前端开发
[回馈]ASP.NET Core MVC开发实战之商城系统(五)
经过一段时间的准备,新的一期【ASP.NET Core MVC开发实战之商城系统】已经开始,在之前的文章中,讲解了商城系统的整体功能设计,页面布局设计,环境搭建,系统配置,及首页【商品类型,banner条,友情链接,降价促销,新品爆款】,商品列表页面,商品详情等功能的开发,今天继续讲解购物车功能开发,仅供学习分享使用,如有不足之处,还请指正。
116 0
|
9月前
|
开发框架 前端开发 .NET
[回馈]ASP.NET Core MVC开发实战之商城系统(一)
[回馈]ASP.NET Core MVC开发实战之商城系统(一)
113 0
|
9月前
|
SQL 开发框架 前端开发
[回馈]ASP.NET Core MVC开发实战之商城系统(开篇)
[回馈]ASP.NET Core MVC开发实战之商城系统(开篇)
144 0