Simply add a HTML meta between
and to automatically refresh the current page or redirect to another website url after a given seconds.1. HTML Meta Auto Refresh
Auto refresh the current page after 60 seconds (1 minute):
<meta http-equiv="refresh" content="60" /> |
2. HTML Meta Auto Redirect
Auto redirect to http://4rapiddev.com after 5 seconds:
<meta http-equiv="refresh" content="5; http://4rapiddev.com" /> |
3. Example
An aspx source file below will display current time and it will be updated after 5 seconds:
+ aspx file:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="auto-refresh-page-after-a-given-seconds.aspx.cs" Inherits="auto_refresh_page_after_a_given_seconds" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Demo Automatically Refresh Current Page After 5 Seconds</title> <meta http-equiv="refresh" content="5" /> </head> <body> <form id="form1" runat="server"> <div> Current Time: <asp:Label runat="server" ID="lblCurrentTime" ForeColor="Blue"></asp:Label> </div> </form> </body> </html> |
+ aspx.cs file:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class auto_refresh_page_after_a_given_seconds : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { lblCurrentTime.Text = DateTime.Now.ToLongTimeString(); } } |