Several groups of data must be refreshed regularly on one of the pages of a project over the past few days. However, each set of data must be refreshed at different times, so multiple timers are required. I have just been working for a while and do not know much about JS Ajax. Instead, I know a little about Microsoft's Ajax. However, when I found that multiple timer and updatepannel were used, the data could not be refreshed directly according to the time set by me. Later, I found that I had to add an updatemode = "Conditional" to control the data, now, paste the code for everyone to learn from each other. If you have something better than me, please kindly advise. Thank you.
Front-end code:
<Asp: scriptmanager id = "scriptmanager1" runat = "server"/>
<Div>
<Asp: updatepanel id = "updatepanel1" runat = "server" updatemode = "Conditional">
<Contenttemplate>
<Asp: textbox id = "textbox1" runat = "server" width = "306px"> </ASP: textbox>
<Asp: timer id = "timer1" runat = "server" interval = "1000" ontick = "timer1_tick">
</ASP: timer>
</Contenttemplate>
</ASP: updatepanel>
</Div>
</Div>
<Asp: updatepanel id = "updatepanel2" runat = "server" updatemode = "Conditional">
<Contenttemplate>
<Asp: textbox id = "textbox2" runat = "server" width = "304px"> </ASP: textbox>
<Asp: timer id = "timer2" runat = "server" interval = "10000" ontick = "timer2_tick">
</ASP: timer>
</Contenttemplate>
</ASP: updatepanel>
Background code:
Protected void timereffectick (Object sender, eventargs E)
{
Textbox1.text = datetime. Now. tostring (); // It is executed once a second.
}
Protected void timer2_tick (Object sender, eventargs E)
{
Textbox2.text = datetime. Now. tostring (); // here you can change it to the method you want to execute. I will replace it with time here, which is intuitive and executed once every 10 seconds.
}