www.webdeveloper.com
Results 1 to 3 of 3

Thread: updating an UpdatePanel each 2 seconds with SetInterval ?

  1. #1
    Join Date
    Mar 2013
    Posts
    1

    updating an UpdatePanel each 2 seconds with SetInterval ?

    Hello everyone, i am new to this forum and also very new to javascript (reads clueless).
    My goal is to call every 10 seconds a WebMethod that returns a string, if the string is not empy i add it to a ListBox inside the UpdatePanel and update the UpdatePanel.

    I have no idea about how to do this

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,434
    Quote Originally Posted by serpiccio View Post
    Hello everyone, i am new to this forum and also very new to javascript (reads clueless).
    My goal is to call every 10 seconds a WebMethod that returns a string, if the string is not empy i add it to a ListBox inside the UpdatePanel and update the UpdatePanel.

    I have no idea about how to do this
    Can you at least provide an HTML layout of the elements you wish to see and/or update?
    This is not a coding service. Please provide a semblance of an attempt!

  3. #3
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,434

    Lightbulb

    Have not a clue if this is what you want to accomplish, so this is just a SWAG!
    Code:
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="utf-8" />
    <title> Untitled </title>
    
    <script type="text/javascript">
    function $_(IDS) { return document.getElementById(IDS); }
    </script>
    
    <style type="text/css">
     #panelDisplay { height:100px; width:200px; background-Color:orange; border:1px solid black; }
    </style>
    
    </head>
    <body>
    <div id="panelDisplay"></div>
    <input id="simSource" type="text" value=""> Simulated input message <br>
    <button onclick="$_('simChange').value=$_('simSource').value; $_('simSource').value = '';">Send</button>
    <input type="hidden" id="simChange" value=""> <!-- information obtained from AJAX source -->
    <p>
    
    <script type="text/javascript">
    function checkAJAX() {
      var tmp = $_('simChange').value;
      if (tmp == '') { return; }
      $_('panelDisplay').innerHTML += tmp+'<br>';
      $_('simChange').value = '';
      return;
    }
    var t = setInterval("checkAJAX()",5000);
    </script>
    
    </body>
    </html>
    It is a simulation only.
    Your information would come from the 'simChange' element obtained via an AJAX call to your server.
    Change the 'hidden' to 'text' to see how the server file would be changed in action.
    The survey of the change event occurs every 5 seconds in this example.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles