Timer control time Timer

Source: Internet
Author: User
The timer control is placed in updatepanl, which is different from the outside. For example, if the interval attribute of the timer control is set to 10000, if the return job takes 2 seconds, it takes 10 seconds to start the timer after the return, that is, 12 seconds to start returning the job. If it is placed outside, it is different. When the return starts to start timing 10 s, that is, 8 s after the return is completed, it starts to return the job again. This is the real 10 jobs.

<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default. aspx. cs" inherits = "_ default" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.1 // en" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> untitled page </title>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
<Div>
<Asp: updatepanel id = "updatepanel1" runat = "server" updatemode = "Conditional">
<Contenttemplate>
<Asp: Label id = "label1" runat = "server" text = "label"> </ASP: Label>
<Asp: timer id = "timer2" runat = "server" interval = "10000" ontick = "timer2_tick">
</ASP: timer>
</Contenttemplate>
<Triggers>
<Asp: asyncpostbacktrigger controlid = "timer1" eventname = "tick"/>
<Asp: asyncpostbacktrigger controlid = "timer2" eventname = "tick"/>
</Triggers>
</ASP: updatepanel>
<Asp: timer id = "timer1" runat = "server" interval = "10000" ontick = "timer1_tick">
</ASP: timer>
</Div>
</Form>
</Body>
</Html>

Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;

Public partial class _ default: system. Web. UI. Page
{
Protected void page_load (Object sender, eventargs E)
{
Label1.text = system. datetime. Now. tostring ();

}

protected void timer2_tick (Object sender, eventargs e)
{< br> label1.text = system. datetime. now. tostring ();
}< br> protected void timereffectick (Object sender, eventargs e)
{< br> label1.text = system. datetime. now. tostring ();
}< BR >}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.