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