<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Label ID="lbtxt" runat="server"></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
</asp:Timer>
</form>
protected void Page_Load(object sender, EventArgs e)
{
//异步回发
ScriptManager1.RegisterAsyncPostBackControl(this.Timer1);
}
protected void Timer1_Tick(object sender, EventArgs e)
{
//lbtxt.Text = DateTime.Now.ToString("hh:MM:ss");
lbtxt.Text = GenerateStringID();
}
private string GenerateStringID()
{
long i = 1;
foreach (byte b in Guid.NewGuid().ToByteArray())
{
i *= ((int)b + 1);
}
return string.Format("{0:x}", i - DateTime.Now.Ticks);
}