Timer控件
<asp:Timer ID="Timer1" runat="server" Interval="1000" ontick="Timer1_Tick">
</asp:Timer>今天是:<asp:Literal ID="LitDate" runat="server"></asp:Literal>
cs:
private void GetTimeString()
{
string week = DateTime.Now.DayOfWeek.ToString().ToLower();
switch (week)
{
case "monday": week = "星期一"; break;
case "tuesday": week = "星期二"; break;
case "wednesday": week = "星期三"; break;
case "thursday": week = "星期四"; break;
case "friday": week = "星期五"; break;
case "saturday": week = "星期六"; break;
case "sunday": week = "星期日"; break;
default:
break;
}
LitDate.Text ="<font color='#ffffff'>"+DateTime.Now.ToString()+" "+week+"</font>";
}
protected void Timer1_Tick(object sender, EventArgs e)
{
GetTimeString();
if (!string.IsNullOrEmpty(NewMail()) && NewMail()!="0")
{
ImgNew.Visible = true;
}
else
{
ImgNew.Visible = false;
}
}