111,126
社区成员
发帖
与我相关
我的任务
分享<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick"></asp:Timer>
<br />
<asp:Label ID="Label1" runat="server" Text="当前时间" Font-Bold="True" Font-Size="Large"></asp:Label></div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Timer1"/>
</Triggers>
</asp:UpdatePanel> public string[] tick_color = { "White", "Silver", "DarkGray","Khaki"};
protected void Timer1_Tick(object sender, EventArgs e)
{
this.Label1.Text = "更新时间:" + System.DateTime.Now.ToString();
int i = System.DateTime.Now.Second % 4;
this.Label1.BackColor = System.Drawing.Color.FromName(tick_color[i]);
}