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