OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

JS function delay on client side C#

  • Thread starter Thread starter MART
  • Start date Start date
M

MART

Guest
I have web app in asp.net which measure database query speed. I created gauge in my html code and have JS function which refresh this gauge like this:

Code:
    window.onload = function () {

        gauge1 = new JustGage({
            id: "gauge1",
            value: 0,
            min: 0,
            max: 10,
            showInnerShadow: true,
            shadowOpacity: 2,
            shadowSize: 5,
        });

    function updateGauge1Value(newValue) {
        gauge1.refresh(newValue);
    }

The aim is that when I click on start button on my webpage, there should start query execute in DS and I want to refresh my gauge after every one query is finished, so it means 100 times in function according to seconds measures on my timer. But the gauge refresh is done just after whole function with finish elapsed time but not when the update function is called via ClientScript, so I want something like this:

Code:
        protected void Button_Click(object sender, EventArgs e)
        {
            //I connect to Database

            for(int i = 0; i < queries.Length; i++){
            //Start timer
            query.Execute();
            string jscode =
            $@"updateGauge1Value(timer.ExecuteSeconds())";

            jscode = "setTimeout(function () {" + jscode + "},1)";
            ClientScript.RegisterStartupScript(Page.GetType(), "myfunc", jscode, true);
            }
         }

It is somehow possible to call my JS function during button click void is executing?

I tried put it into different functions, but doesn't help.

<p>I have web app in asp.net which measure database query speed. I created gauge in my html code and have JS function which refresh this gauge like this:</p>
<pre><code> window.onload = function () {

gauge1 = new JustGage({
id: "gauge1",
value: 0,
min: 0,
max: 10,
showInnerShadow: true,
shadowOpacity: 2,
shadowSize: 5,
});

function updateGauge1Value(newValue) {
gauge1.refresh(newValue);
}
</code></pre>
<p>The aim is that when I click on start button on my webpage, there should start query execute in DS and I want to refresh my gauge after every one query is finished, so it means 100 times in function according to seconds measures on my timer. But the gauge refresh is done just after whole function with finish elapsed time but not when the update function is called via ClientScript, so I want something like this:</p>
<pre><code>
protected void Button_Click(object sender, EventArgs e)
{
//I connect to Database

for(int i = 0; i < queries.Length; i++){
//Start timer
query.Execute();
string jscode =
$@"updateGauge1Value(timer.ExecuteSeconds())";

jscode = "setTimeout(function () {" + jscode + "},1)";
ClientScript.RegisterStartupScript(Page.GetType(), "myfunc", jscode, true);
}
}
</code></pre>
<p>It is somehow possible to call my JS function during button click void is executing?</p>
<p>I tried put it into different functions, but doesn't help.</p>
 

Online statistics

Members online
0
Guests online
4
Total visitors
4
Top