本文介绍了如何获得当前的月份和年份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我如何获取当前月份和年份并将其显示在ASP.NET的标签中吗?
Can anybody tell me that how I can get current month and year and show it in a label in ASP.NET?
推荐答案
如果您具有以下两个标签:
If you have following two labels:
<asp:Label ID="MonthLabel" runat="server" />
<asp:Label ID="YearLabel" runat="server" />
比起您可以使用以下代码,只需要为这些标签设置文本属性",例如:
Than you can use following code just need to set the Text Property for these labels like:
MonthLabel.Text = DateTime.Now.Month.ToString();
YearLabel.Text = DateTime.Now.Year.ToString();
这篇关于如何获得当前的月份和年份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!