龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > web编程 > asp.net编程 >

ASP.NET显示农历时间改进版(2)

时间:2014-11-18 11:05来源:网络整理 作者:网络 点击:
分享到:
需要的using 复制代码 代码如下: using System; using System.Collections.Generic; using System.Web; using System.Text; using System.Globalization; 调用: 复制代码 代码如下: CountryD

需要的using

复制代码 代码如下:
using System; 
using System.Collections.Generic; 
using System.Web; 
using System.Text; 
using System.Globalization;

调用:
复制代码 代码如下:
CountryDate cd = new CountryDate(); 
string ChineseTimeNow = cd.GetChineseDate(DateTime.Now);//农历日期 
string ForignTimeNow = DateTime.Now.GetDateTimeFormats('D')[0].ToString();//公历日期

下面有一个测试的效果:

前台代码:

复制代码 代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="TestCountryDate._Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
    <title></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div> 
    <table> 
     <tr> 
      <td><asp:Label ID="Label1" runat="server" Text="农历时间"/></td> 
      <td><asp:Label ID="lblCountryDate" runat="server"/></td> 
     </tr> 
     <tr> 
      <td><asp:Label ID="Label2" runat="server" Text="公历时间"/></td> 
      <td><asp:Label ID="lblForignDate" runat="server"/></td> 
     </tr> 
    </table> 
    <asp:Button ID="buttton1" runat="server" Text="显示时间" OnClick="Button1_Click" /> 
    </div> 
    </form> 
</body> 
</html>

精彩图集

赞助商链接