Timer controls need to be implemented without refreshing, and Ajax technology is needed. We can use Ajax technology that comes with vs2008. First, you must add a scriptmanager control, and then add an updatepanel to store the timer control content. The details are as follows:
I. Front-end:
<Form ID = "form1" runat = "server">
<Asp: scriptmanager id = "scriptmanager1" runat = "server">
</ASP: scriptmanager>
<Asp: updatepanel id = "updatepanel1" runat = "server">
<Contenttemplate>
<Asp: timer id = "timer1" runat = "server" interval = "60000" ontick = "timer1_tick">
</ASP: timer>
</Contenttemplate>
</ASP: updatepanel>
</Form>
Remember that scriptmanager must be placed in the <form> label and can be placed anywhere. After the updatepanel control is added, a very important attribute contenttemplate needs to be used. Otherwise, no refreshing effect will be achieved. Here we set a scheduled event to be triggered every 6 seconds.
Ii. Background code
Protected void page_load (Object sender, eventargs E)
{}
Protected void timereffectick (Object sender, eventargs E)
{
// Here you can operate on what you want to do, such as regular query database
Scriptmanager. registerstartupscript (this, this. GetType (), "", "alert ('hello');", true );
}
Here, I implemented the pop-up dialog box "hello" every six seconds.