ASP.NET显示农历时间改进版(2)
需要的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;
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();//公历日期
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>
<!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>
- 上一篇:ASP.NET MVC小结之基础篇(一)
- 下一篇:ASP.NET显示农历时间的方法
收藏文章
精彩图集
精彩文章