This article describes the implementation method of Timer refresh-free timer. To achieve refresh-free Timer control, ajax technology must be used, which uses the ajax technology that comes with VS2008.
First, you have to add a ScriptManager control, and then add an UpdatePanel to store the contents of the Timer control, and you can achieve no refresh. The following are the details:
1. The front desk code is as follows:
<form 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 to place the ScriptManager in the <form> tag, and can be placed anywhere. After adding the UpdatePanel control, it needs to use its very important property ContentTemplate, otherwise it will not be able to achieve a refresh-free effect. Here we set a 6-second timing trigger event once.
2. The background code is as follows:
protected void Page_Load(object sender, EventArgs e) {} protected void Timer1_Tick(object sender, EventArgs e) { //This can operate what you want to do, such as querying the database regularly(this, (), "", "alert('Hello‘);", true); }
I hope the examples described in this article will be helpful to everyone's programming.