Auto Update Div or page Every X Seconds

auto page Updates Every X Seconds


Download Code

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="AutoUpdateDiv.Default" %>

<!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>Auto update div | lesson8</title>
    <script src="Scripts/jquery-1.4.1.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            updateLoggedInUsersModule();
            window.setInterval(updateLoggedInUsersModule, 10000)
        });

        function updateLoggedInUsersModule() {
            $('#ModuleUpdateStatus').html('Loading ...').fadeIn('fast');
            $('#UsersModule').load('About.aspx', function (response, status, xhr) {
                $('#ModuleUpdateStatus').fadeOut('fast');
            });
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Generated at
        <%= DateTime.Now %>
        <br />
        <br />
        <div id="UsersModule">
        </div>
        <div id="ModuleUpdateStatus">
        </div>
    </div>
    </form>
</body>
</html>

About.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="About.aspx.cs" Inherits="AutoUpdateDiv.About" %>

<!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>auto page Updates Every X Seconds | lesson8</title>
</head>
<body>
    <form id="form1" runat="server">
    <div style="background-color: Gray; color: White; font-size: 20px;">
        Welcome About
        <br />
        <%= DateTime.Now %>
    </div>
    </form>
</body>
</html>
Auto Update Div or page Every X Seconds Auto Update Div or page Every X Seconds Reviewed by Bhaumik Patel on 1:15 AM Rating: 5