Timer No Refresh Timer

Source: Internet
Author: User
Timer No Refresh timerCategory: asp.net--Web 2011-08-08 16:27 100 People Reading reviews (0) Favorite reports

The timer control to implement no refresh, the use of Ajax technology, we can use VS2008 Ajax technology. The first thing you need to do is add a ScriptManager control, and then add a UpdatePanel to hold the contents of the Timer control, and you can implement no refresh. Here's what it's all about:

First, the front desk:

 <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 ScriptManager must be placed in the <form> tag, can be placed in any place. After adding the UpdatePanel control, it is necessary to use a very important property contenttemplate, otherwise it will not be able to achieve no refresh effect. Here we set the 6-second timer to trigger the event once.

Second, backstage code

protected void Page_Load (object sender, EventArgs e)
{}

protected void Timer1_Tick (object sender, EventArgs e)
{

Here you can do what you want to do, such as querying the database regularly

Scriptmanager.registerstartupscript (this, this.) GetType (), "", "alert (' Hello ');", true);

}

Here I implement the content of the dialog hello that pops up every 6 seconds.

http://blog.csdn.net/loveheronly/article/details/6669660%E5%B0%B1%E6%98%AF%E6%97%A0%E5%88%B7%E6%96%B0%E7%9A%84

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.