asp.net中如何将阳历转化为阴历(C#)
2008-12-05 16:28
344 查看
我们有的时候会用到阴历来做一些事情,在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;
}
}
}
前台:
<%@ 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;
}
}
}
相关文章推荐
- 在Asp.Net中如何将从SQL读出来的表转化成XML文件并保存在指定的位置中用C#
- 如何用asp.net+c#删除本地硬盘上的文件?
- asp.net中如何通过javascript触发c#代码
- asp.net中如何把Access数据库转化成SQL数据库
- C#、Asp.Net 农历与阴历之间相互转化工具类
- 在Asp.Net中如何将从SQL读出来的表转化成XML文件并保存在指定的位置中
- 如何在ASP.NET MVC 2中使用jQuery UI控件
- 如何:在 ASP.NET(c#) 网页中检测浏览器类型
- asp.net如何disableButton,同时触发后台事件
- ASP.NET 如何有效的防止资源被盗(防盗链下载)
- 如何实现Asp与Asp.Net共享Session
- 转贴(csdn):ASP.NET Web 服务如何工作
- 如何在asp.net中调用存储过程?
- ASP.NET如何输出刷新父窗口脚本语句
- 在asp.net ajax 1.0 的updatePanel中如何实现文件下载
- ASP.NET中如何把EXCEL中数据导入到SQL SERVER
- 如何高亮ASP.NET MENU 的父节点
- 如何使用asp.net 开发 ext 2.0 tree ?
- MVC学习十四:ASP.NET MVC如何实现自定义验证 AgeRangeAttribute
- 如何在Asp.net中实现多彩下拉框