C # one page, multiple updatepannel and multiple timers

Source: Internet
Author: User

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.

}

Related Article

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.