locked
problem of image refreshed (aspx, c#, javascript) RRS feed

  • Question

  • User-458598543 posted

    hello,

    i've got a problem of image refreshed. well, i had designed a picture with the c# classes bitmap, graphics, drawing and ellipse in a aspx page and i must insert this image in an other aspx page. this drawing must be updated each interval in a setInterval javascript function. the problem is that the image is not refreshing. the update consisted to change the colors of the figures each interval.

    code :

    <body id="body_1" class="body_style" onload="action_diaporama()">

    <image id="img_2" style="width: 600px; heigth: 100%;" class="element"></image>

    </body>

    <script>

    function action_diaporama()
    {

    setInterval("diaporama_1()", 6000);

    }

    function diaporama_1()
    {

    var_drawing = document.getElementById("img_2");
    var_drawing.src = WF1_Drawing_2.aspx";

    }

    </script>

    thanks you.

    Wednesday, January 27, 2021 10:23 PM

Answers

  • User475983607 posted

    Probably browser cache.  Try the following.  In the future share code without syntax errors so we can focus on the actual issue.

        <script>
            function action_diaporama() {
                setInterval("diaporama_1()", 1000);
            }
    
            function diaporama_1() {
                console.log('tick');
                var_drawing = document.getElementById("img_2");
                var_drawing.src = "/images/guitar_PNG3338.png?ts=" + new Date().toISOString();
            }
        </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 27, 2021 11:32 PM

All replies

  • User475983607 posted

    After fixed the coding errors, I came up with the following working example.

    <!DOCTYPE html>
    
    <html>
    <head>
        <meta name="viewport" content="width=device-width" />
        <title>Index</title>
    </head>
    <body id="body_1" class="body_style" onload="action_diaporama()">
        <image id="img_2" style="width:600px;height:100%;" class="element"></image>
        <script>
            function action_diaporama() {
                setInterval("diaporama_1()", 6000);
            }
    
            function diaporama_1() {
                var_drawing = document.getElementById("img_2");
                var_drawing.src = "/images/guitar_PNG3338.png";
            }
        </script>
    </body>
    </html>

    I replaced "WF1_Drawing_2.aspx" with an actual image; "/images/guitar_PNG3338.png".  I went this route because you did not include the code for WF1_Drawing_2.aspx.

    Wednesday, January 27, 2021 10:41 PM
  • User-458598543 posted

    hello,

    the problem doesn' concerned the execution of setInterval method but the problem concerns the refresh of the image. i've no problem of the time elapsed execution of setInterval function. so, the image is drawned in a aspx page with the c# classes and normally the background-color of elements must changed. when i execute this drawing page single, the process of changing colors is operationnal, i can reload the page and the background-colors are changed ; for your govern i used a system.random function applied on color rgb class.

    the work is that i want that theses colors are changing automatically in an other page with the setInterval function.

    so the drawing page is charged each 6 secondes in the master page but the background-Colors didn't changed.

    well, i hope that i have suffisant explicit.

    thank you.

    Wednesday, January 27, 2021 11:17 PM
  • User475983607 posted

    Probably browser cache.  Try the following.  In the future share code without syntax errors so we can focus on the actual issue.

        <script>
            function action_diaporama() {
                setInterval("diaporama_1()", 1000);
            }
    
            function diaporama_1() {
                console.log('tick');
                var_drawing = document.getElementById("img_2");
                var_drawing.src = "/images/guitar_PNG3338.png?ts=" + new Date().toISOString();
            }
        </script>

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, January 27, 2021 11:32 PM
  • User-458598543 posted

    great, the function is operational. it was a problem of cache.

    thanks you.

    Thursday, January 28, 2021 12:14 AM