我们有的时候会用到阴历来做一些事情,在1.1的时候,只能用第三方的方法。现在2.0中给了自己的方法,不多说了,放一个例子。
前台:
后台“
前台:
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm2.aspx.cs" Inherits="WebApplication1.WebForm2" %>
- <!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>
- 请输入阳历日期:<asp:TextBox ID="txtSun" runat="server"></asp:TextBox>
- <br />
- <br />
- 阳历日期:<asp:TextBox ID="txtMoon" runat="server" ></asp:TextBox>
- <br />
- <br />
- <asp:Button ID="Button1" runat="server" Text="转换" onclick="Button1_Click" />
- </div>
- </form>
- </body>
- </html>
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Globalization;
- namespace WebApplication1
- {
- public partial class WebForm2 : System.Web.UI.Page
- {
- private ChineseLunisolarCalendar chineseDate = new ChineseLunisolarCalendar();
- protected void Page_Load(object sender, EventArgs e)
- {
- }
- protected void Button1_Click(object sender, EventArgs e)
- {
- string Moon = chineseDate.GetYear(Convert.ToDateTime(this.txtSun.Text.Trim())).ToString() + "-" + chineseDate.GetMonth(Convert.ToDateTime(this.txtSun.Text.Trim())).ToString() + "-" + chineseDate.GetDayOfMonth(Convert.ToDateTime(this.txtSun.Text.Trim()));
- this.txtMoon.Text = Moon;
- }
- }
- }