Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8174413
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:27:08+00:00 2026-06-06T22:27:08+00:00

I have an aspx web form in a WCF service project that gives a

  • 0

I have an aspx web form in a WCF service project that gives a status report on that service. Currently I have a Refresh button, but I’d like to automate a regular periodic refresh.

I’ve tried two ways:

  1. A javascript inside <head> using setInterval() and started in Page_Load with RegisterStartupScript.
  2. A Systems.Timers.Timer inside Page_Load, doing what the button click would do.

I don’t get (1) right because of an obvious scope problem and I’m clearly misunderstanding how it should work. Currently the script simply does an alert, and I can’t get further.

I don’t get (2) right, though it seems as if it should work, because putting a breakpoint into the timer function shows correct values, but the form labels on the page don’t update.

The webform.aspx looks as follows:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Manage.aspx.cs" Inherits="MyServiceWS.ManageForm" %>

<!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>Manage</title>
    <script type="text/javascript">
        // method (1)
        RefreshScript = function ()
        {
            setInterval(function () { alert("How to call the Refresh code?"); }, 5000);
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <p>
                Synchronisation status: 
                <asp:Label ID="SyncStatusLabel" runat="server" />
                <p>
                <asp:Button ID="RefreshButton" runat="server" Text="Refresh" 
                    onclick="RefreshButton_Click" />
                <p>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    </form>
</body>
</html>

The c# code in the webform.aspx.cs looks as follows. This is where the desired refresh code resides. Of course I only try one method at a time, they’re both uncommented below for clarity as to what I’ve been trying.

namespace MyServiceWS
{
    public partial class ManageForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            // method (1)
            ClientScript.RegisterStartupScript(this.GetType(), "addScript", "RefreshScript()", true);

            if (Page.IsPostBack)
                Refresh();
            else
            { // method (2)
                var myTimer = new System.Timers.Timer();
                myTimer.Elapsed += new ElapsedEventHandler(TimedRefreshEvent);
                myTimer.Interval = 5000;
                myTimer.Start();
            }
        }
        protected void RefreshButton_Click(object sender, EventArgs e)
        {
            Refresh();
        }

        private void TimedRefreshEvent(object source, ElapsedEventArgs e)
        {
            Refresh();
        }

        private void Refresh()
        {
            SyncStatusLabel.Text = Global.StatusDescription;
        }
    }
}

A Global.asax file contains the static string variable StatusDescription which correctly contains a status that is populated elsewhere by the service.

I’m stumped, are either methods correct, and how do I proceed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T22:27:08+00:00Added an answer on June 6, 2026 at 10:27 pm

    Change this:

    RefreshScript = function () 
            { 
                setInterval(function () { alert("How to call the Refresh code?"); }, 5000); 
            } 
    

    To:

    function RefreshScript()
    { 
         setInterval(function () { alert("How to call the Refresh code?"); }, 5000); 
    } 
    

    And see if that works better.

    You can also use the timer approach, but not through System.Timers.Timer; use the ASP.NET AJAX timer control.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
I have a WCF web service called Palladium that is created as a project
I have a web page (.aspx) that calls a third party web service to
I have a control that can be placed in a Web form (.aspx) or
I have a web form page Default.aspx, which inherits from a BasePage class that
I have a .aspx Web Form with a .aspx.cs code-behind. The code-behind is nearly
my structure is like this: master page aspx(web form) ascx(user control) I have a
I have a huge ASPX web form which has around 100 fields which need
I have many aspx page includes in my web form. I want to convert
I have an asp.net web form with an html input and button at the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.