青春几米光

点击这里给我发消息

导航

timer控件控制显示系统时间,随时更新

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;
        }
    }

posted on 2013-01-11 17:35  青春几米光  阅读(390)  评论(0编辑  收藏  举报