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

  • SEARCH
  • Home
  • 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 985933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:14:28+00:00 2026-05-16T05:14:28+00:00

I’m having a serious problem with my ASP.NET AJAX application. There is a javascript

  • 0

I’m having a serious problem with my ASP.NET AJAX application.

There is a javascript function in my application needs to be executed after the Timer_Tick event. Here’s the code behind:

void SetValues()
   {
   try 
   {
   StringBuilder sbScript = new StringBuilder();
   sbScript.Append("<script language='javascript' type='text/javascript'>");
   sbScript.Append("function UpdateValue() {");
   for (int j = 0; j < iTotalDevices; j++)
   {
   sbScript.Append("setElementValue(" + j.ToString() + "," + DevicesInfo[j].X.ToString() + "," + DevicesInfo[j].Y.ToString() + "," + iStatus.ToString() + "," + DevicesInfo[j].DeviceID.ToString() + ");");
   }
   sbScript.Append("}");
   sbScript.Append("</script>");
   ScriptManager.RegisterStartupScript(this, this.GetType(), "myscript", sbScript.ToString(), false);
   }
   catch 
   { }
   }

protected void Timer1_Tick(object sender, EventArgs e)
{
    ///This function will get latest values from database
    GetNewData();
    SetValues();
}

When I call the javascript function ‘UpdateValue’ for the first time (at onload page event), it works correctly. But after the Timer_Tick event, it does nothing. This is the HTML code:

<script type="text/javascript" language="javascript">
function PageLoad() {
///Call function for the first time and it works
UpdateValue();
}

function setElementValue(index, value1, value2, value3...) {
///Set value for each element in object array
}

</script>
<body onload="PageLoad()">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:Timer ID="Timer1" runat="server" OnTick="Timer1_Tick" Interval="30000">
</body>

What’s the problem with the ScriptManager or the Timer_Tick event?

Many thanks,

  • 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-05-16T05:14:28+00:00Added an answer on May 16, 2026 at 5:14 am

    It looks like you’re registering the UpdateValue function each time Timer1_Tick executes.

    Try changing your SetValues function to this:

    void SetValues()
    {
       try 
       {
           StringBuilder sbScript = new StringBuilder();
           sbScript.Append("<script language='javascript' type='text/javascript'>");
           for (int j = 0; j < iTotalDevices; j++)
           {
           sbScript.Append("setElementValue(" + j.ToString() + "," + DevicesInfo[j].X.ToString() + "," + DevicesInfo[j].Y.ToString() + "," + iStatus.ToString() + "," + DevicesInfo[j].DeviceID.ToString() + ");");
           }
           sbScript.Append("</script>");
           ScriptManager.RegisterClientScriptBlock(this, this.GetType(), string.Format("myscript{0}", DateTime.Now.ToString("yyyyMMddHHmmss")), sbScript.ToString(), false);
       }
       catch 
       { }
    }
    

    EDIT: Notice that I’m using RegisterClientScriptBlock instead of RegisterStartupScript. Also, “myscript” should be a unique key, so I just updated that part.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I need a function that will clean a strings' special characters. I do NOT

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.