Hi all,

First time poster, but I'd like to ask a simple question in ASP.NET C#.

I have a function that sends queries to an SQL Server. It takes a while, so I'd like to display the details to the user. Something simple, like "Sending x out of 12345 total queries" with x constantly updating without interfering with the user. I tried I'd really prefer to display it on the page without adding too much to the code.

mydata = "Sending " + begin.ToString() + " out of " + end.ToString() + " total queries.";
        Response.Buffer.Equals(true);
        Response.Flush();
        lblProgress.Text = mydata;

This is the idea of what I'm looking for.
I'd like to avoid adding some ridiculous AJAX library for now.

The following code has an idea of what I'm looking for. I found some sample code that will send JavaScript, but that didn't seem to work on my page. The second part of that function is what I tried, but I know it won't really work.

public void myLongRunningJob(int begin, int end)
    {
        string mydata;
        mydata = "<script>UpdateStatus(" + begin + ", " + end + ");</script>";
	    Response.Write(mydata);
		Response.Flush();
        System.Threading.Thread.Sleep(90);
      
    }
<script language="javascript" type="text/jscript">
    function UpdateStatus(i, j) {
            var obj = document.getElementById("status");
        obj.innerHTML = "Sending " + i + " out of " + j + " total queries.";
    }

</script>

Thanks for any reply.

I tried editing the thread name. Apologies for the nondescriptive thread title.

Thanks, that seems to be something I'm looking for.

However, I'd like to also asynchronously view a variable when the timer control refreshes. Right now, I am sending queries, and I count the number of queries sent so far in an int.

The problem with the timer function is that it doesn't pull the value of the int while it's running. It only seems to pull it after the for loop is done.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.