Truemag

  • Categories
    • Tips And Tricks
    • Internet
    • PHP
    • Javascript
    • CSharp
    • SQL Server
    • Linux
  • Lastest Videos
  • Our Demos
  • About
  • Contact
  • Home
  • Write With Us
  • Job Request
Home Tips And Tricks Create Auto Refresh Page Or Redirect After A Given Seconds

Create Auto Refresh Page Or Redirect After A Given Seconds

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" />

<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" />

<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>

<%@ 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();
    }
}

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(); } }

Mar 22, 2012Hoan Huynh

Source Code Demo page

JQuery How to use DatePickerHTTP/ HTTPS Document, CGI-BIN And Access/ Error Logs On cPanel, Plesk And VirtualMin
You Might Also Like:
  • Create Count Down Download Page With JavaScript
  • Auto Rotate Web Page Title With JavaScript
  • Auto Convert Text To URL Link And MailTo Email Address With ASP.NET C#
  • C# Save Web Page URL To Image
  • PHP auto post tweet to Twitter
  • Create A New Template For WordPress Page
  • Create Custom Update Profile Page For WordPress Users
  • How To Ask People To Like Your Facebook Page On The Landing Page
  • Disable Auto Save Password In HTML Form Or TextBox
  • Show Error Message On WordPress Custom Login Template Page
Hoan Huynh

Hoan Huynh is the founder and head of 4rapiddev.com. Reach him at [email protected]

10 years ago Tips And TricksHTML, http-equiv, refresh, ToLongTimeString204
0
GooglePlus
0
Facebook
0
Twitter
0
Digg
0
Delicious
0
Stumbleupon
0
Linkedin
0
Pinterest
Most Viewed
PHP Download Image Or File From URL
24,469 views
Notepad Plus Plus Compare Plugin
How To Install Compare Text Plugin In Notepad Plus Plus
21,844 views
Microsoft SQL Server 2008 Attach Remove Log
Delete, Shrink, Eliminate Transaction Log .LDF File
17,661 views
JQuery Allow only numeric characters or only alphabet characters in textbox
15,004 views
C# Read Json From URL And Parse/Deserialize Json
11,737 views
4 Rapid Development is a central page that is targeted at newbie and professional programmers, database administrators, system admin, web masters and bloggers.
Recent Posts
  • Things to Learn about Installingderm Loan Type S
  • Online Photo Editor – Free Photoediting Software
  • A Guide to Finding the Best Paper Sellers
  • Photoediting in Home Isn’t Hard to Do!

  • Free Photo Editor Online
Categories
  • CSharp (45)
  • Facebook Graph API (19)
  • Google API (7)
  • Internet (87)
  • iPhone XCode (8)
  • Javascript (35)
  • Linux (27)
  • MySQL (16)
  • PHP (84)
  • Problem Issue Error (29)
  • Resources (32)
  • SQL Server (25)
  • Timeline (5)
  • Tips And Tricks (141)
  • Uncategorized (647)
Recommended
  • Custom Software Development Company
  • Online Useful Tools
  • Premium Themes
  • VPS
2014 © 4 Rapid Development