You must Sign In to post a response.
  • Category: ASP.NET

    Automatic refresh ASP.NET page ..

    I have gmap on asp page I want refresh that page on interval like after every 5 minutes...
  • #647815
    Hello,

    please check below code:

    Refresh document every 300 seconds:
    <meta http-equiv="refresh" content="300" />




    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html>
    <head>
    <meta http-equiv="refresh" content="300" />

    <title>Google Maps</title>
    <script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=" type="text/javascript"></script>
    </head>
    <body >
    <div id="map" style="width: 550px; height: 450px"></div>

    <script type="text/javascript">


    if (GBrowserIsCompatible()) {


    function createMarker(point,html) {
    var marker = new GMarker(point);
    GEvent.addListener(marker, "click", function() {
    marker.openInfoWindowHtml(html);
    });
    return marker;
    }

    var map = new GMap2(document.getElementById("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.setCenter(new GLatLng(17.5304303,73.8567437),5);

    var point = new GLatLng(18.5244303,78.8567537);
    var marker = createMarker(point,'<div style="width:240px">Marker1<\/div>')
    map.addOverlay(marker);

    }

    else {
    alert("Sorry, the Google Maps API is not compatible with this browser");
    }


    </script>
    </body>

    </html>

    Regards
    Mr.Rajesh
    Software Engg.

  • #647817
    Use this code in the aspx page

    <HEAD>
    <title>WebForm1title>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <!--The next line of code will refresh the page every 5 minutes-->
    <meta http-equiv="refresh" content="300">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="http://schemas.microsoft.com/intellisense/ie5"
    name="vs_targetSchema">
    HEAD>

    Ref:

    SQL Server Programmers and Consultants

  • #647818
    HI

    Automatic web page refresh can be implemented in an ASP.NET (.aspx) web-page by adding some HTML code in the header section.

    You can simply add following line of code in the Header section to enable auto refresh in an ASP.NET web page.

    <meta http-equiv="refresh" content="15">

    Also you can redirect to a specific page if you put the URL inside the tag.

    <meta http-equiv="refresh" content="15;url=http://www.portinggurus.com">


    If you want to set the refresh time dynamically then that can be done in ASP.NET by adding server side code in the Page_Load function to set it, as shown below:

    Response.AppendHeader("Refresh", "15")

  • #647820
    thank you Software Engg.

    this code work in my site ..

    Regards
    Sagar pawar
    Software developer

  • #647826

    You can use the below scrtipt to refresh the page in every specified time interval.


    <meta http-equiv="refresh" content="5" />



    You can also redirect to any site say http://mannpandey.blogspot.com/ after 5 seconds:

    <meta http-equiv="refresh" content="5;url=http://mannpandey.blogspot.com/" />




    Redirect to http://example.com/ immediately:

    <meta http-equiv="refresh" content="0;url=http://example.com/" />



    Thanks & Regards
    Anil Kumar Pandey
    Microsoft MVP, DNS MVM

  • #647827
    In this Sample page the page will refresh every 10 secs.

    In the Timer1_Tick page you can either redirect to the same page or call a particular method which will do the job for your refresh

    aspx body:
    <body>
    <form id="form1" runat="server">
    <asp:ScriptManager runat="server" id="ScriptManager1" />
    <asp:Timer ID="Timer1" runat="server" Interval="10000" ontick="Timer1_Tick" ></asp:Timer>

    <div>
    This Page will refresh in 10 mins
    </div>
    </form>
    </body>


    aspx.cs :

    protected void Timer1_Tick(object sender, EventArgs e)
    {
    Response.Redirect("~/AutorefreshAPage.aspx");
    }

  • #647853
    You may use one of the following code:

    1) Using <meta> tag:


    <meta http-equiv="refresh" content="5; URL=PageToBeFreshed">


    2) Using JavaScript's setTimeOut function:


    <body onload="javascript:setTimeout("location.reload(true);",5);">


    Thanks & Regards
    Paritosh Mohapatra
    Microsoft MVP (ASP.Net/IIS)
    DotNetSpider MVM

  • #648488
    Hi!
    You can refresh the page automatically if you set the time for interval
    Hope the code given below will hel you

    setTimeout("location.reload(true);", timeout);

    The second is a Meta tag:
    <meta http-equiv="refresh" content="600">

    You can set the refresh intervals on the server side

    Regards
    Kamlesh

    Regards
    Kamlesh Mohanty


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.