Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Progressbar at runtime in asp.net

Status
Not open for further replies.

cyberdeminout

Programmer
Jul 19, 2005
37
US
Hi

Can anyone help me how to show progress bar at runtime in asp.net(language=vb).

Thanks in advance.

Ram
 
crudely written code:
Code:
<%@ import namespace="System.Threading"%>
<script>
	function ShowProgress(Current,Total)
	{
		document.getElementById("ProgDiv").innerHTML=(Current/Total)*100+"%"
	}
</script>
<body>
<div id="ProgDiv"></div>
</body>
<script runat="server">
Shared waitTime As New TimeSpan(0, 0, 1)
Dim newThread As New Thread(AddressOf Work)
Shared Sub Work()
	Thread.Sleep(waitTime)
End Sub
</script>
<%
	dim i as integer
	newThread.Start()
	for i=1 to 20
%>
	<script>ShowProgress(<%=i%>,20)</script>
<%	
		response.flush()
		newThread.sleep(1000)
	next
	response.write("DONE")
%>

Known is handfull, Unknown is worldfull
 
and could someone clean up this code (i would like to implement the same using using code behind)...

Known is handfull, Unknown is worldfull
 
well, did anyone try it out???

Known is handfull, Unknown is worldfull
 
vbkris
Yes, I took your code and just made it work as a single page code. It needed a little tweaking.
Code:
<%@ import namespace="System.Threading"%>
<html>
<script language="vb" runat="server">
Dim waitTime As New TimeSpan(0, 0, 1)
Dim newThread As New Thread(AddressOf Work)
Sub Work()
    Thread.Sleep(waitTime)
End Sub
</script>
<body>
<form runat="server" ID="Form1">
<div id="ProgDiv"></div>
<script>
    function ShowProgress(Current,Total)
    {
        document.getElementById("ProgDiv").innerHTML=(Current/Total)*100+"%"
    }
</script>

<%
    dim i as integer
    newThread.Start()
    for i=1 to 20
%>
    <script>ShowProgress(<%=i%>,20)</script>
<%    
        response.flush()
        newThread.sleep(1000)
    next
    response.write("DONE")
%>
</form>
</body>
</html>
Now I'm not the brightest bulb on the tree but I do not understand how this will work with codehehind. If you update your value in the codebehind that the javascript is to use then you would have post back and forth many times. How else would the javascript get the new value? Please excuse my ignorance may be you can help me understand your code.
Marty
 
>> but I do not understand how this will work with codehehind


same problem here...

Known is handfull, Unknown is worldfull
 
Another alternative is to get the page to refresh to update the status e.g.


If this could be coupled with XMLHTTP, then you could implement a real-time status that didn't refresh the whole page.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.
 
Another solution that could be used is to use an Iframe which points to an aspx page which submits itself at regular intervals and display a progress bar inside the Iframe.


Sunil
 
that would not be real time!!!

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top