473,388 Members | 1,277 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Creating a Progress Bar for Uploads in DotNet (VB.NET)

Here is how to build a progress bar in dotnet that doesn't require any
third party components and uses JavaScript on the client side so it
doesn't require any additional post backs.

This script works perfect for uploads, or any operation that requires
a significant amount of processor time on the server.

-------------------------------------------------------------------------------
In the header of your aspx page...

<script language="JavaScript">
<!-- Begin

// This part switches the image on the onClick

if (document.images) {
nav1 = new Image();
// YOUR ANIMATED GIF GOES HERE!
nav1.src = "Images/processing.gif";
}

// Trick Javascript into generating a new thread

function threadStart(imgName) {
t = 200;
setTimeout("imgOn('" + imgName + "')", t)
}

// Function to activate image

function imgOn(imgName) {
if (document.images) {
document[imgName].src = eval(imgName + ".src");
document.all.Label.style.visibility="hidden";
document.body.style.cursor = "wait";
}
}

// End -->
</script>

In the body... The first cell is an image of one pixel. The second
cell of the table (with the <div> tags) ensures that if you are
displaying an error
message or some other text it should disappear on the onClick event.

Image tag for the loading button...

<table>
<tr>
<td>
&nbsp;<img src="Images/dot.gif" border="0" Name="nav1">
</td>
<td>
<div id = Label>
<asp:label id="ErrorMessage" runat="server" Font-Bold="true"/>
</div>
</td>
</tr>
</table>
Here is the LinkButton that triggers the event (Pretend it's in a
datagrid)...

<asp:DataGrid>

<asp:LinkButton ID="ApproveIt" Runat="server" Text="cLICK ME"
CommandName="OK_Command" CausesValidation="False" Font-Size="9"
Font-Bold="true" ForeColor="#33cc66" />

</asp:DataGrid>
-------------------------------------------------------------------------------

In the code behind...

Sub DEDR_ItemCommand(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataGridCommandEventArgs ) Handles
EventData.ItemCommand

'// Calls the Key ID Number of the Field from the DataGrid
Dim idNum As Integer = CType(e.Item.Cells(0).Text, Integer)

'// Some SQL operation goes here
If (e.CommandName = "OK_Command") Then
...Some operation on idNum
End If

End Sub

'// This writes the grid so that there is a confirm box attached to
each LinkButton in DataGrid

Sub EventData_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles EventData.ItemDataBound

Dim m As LinkButton

If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType =
ListItemType.AlternatingItem Then

m = CType(e.Item.FindControl("ApproveIt"), LinkButton)
m.Attributes.Add("onclick", "if (confirm('Approve this item?')
== true) threadStart('nav1');")

End If

End Sub
Nov 17 '05 #1
0 1366

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: rr | last post by:
Environment: Development PC: W2K Professional WebServer: W2K Server, IIS 5.0 Peer-to-Peer network I'd like to create a new asp.net project on a remote server (not on the local (development)...
1
by: Hvitebj?rn | last post by:
I have created a graphical control using C#.NET and made it COM-compatible using the method described here: http://www.codeproject.com/cs/miscctrl/exposingdotnetcontrols.asp Adding the control...
4
by: raghavendra | last post by:
Hi, Can anyone of u give me a pointer how to create a new .chm file.. One more thing is can i update the existing .chm file with some more information embedded in the xml file. Thanks &...
1
by: Torrence Alvin | last post by:
I'm using Visual Studio .NET 2003 and get the following message error message creating a C# ASP.NET application: "The web server reported the following error when attempting to create or open...
1
by: Arvind P Rangan | last post by:
Hi, I have tried creating folders through ASP.Net with Directory.Create(path) But it gives me error mscorlib Access to the path "C:\WINNT\system32" is denied. at...
1
by: Garett | last post by:
I am creating a document manager of sorts in ASP.net and it would be really nice to have some sort of file upload progress bar for larger files. Companies such as www.websupergoo.com and...
0
by: Arvind P Rangan | last post by:
Hi, I have tried creating folders through ASP.Net with Directory.Create(path) But it gives me error mscorlib Access to the path "C:\WINNT\system32" is denied. at...
1
by: Patrick Spence | last post by:
VS.NET 2003 v 7.1.3088 ..NET Framework v1.1.4322 XP Pro IIS 5.0 When I try to create a ASP.NET application, I get the following error... The Web server reported the following error when...
5
by: suganya | last post by:
i am new to vb.net. i am trying to create a class library ( equivalent of vb's dll) in vb.net . i checked the 'register for COM interop' option and built the app. a dll ic cretaed but i am not able...
2
by: Jon Masterson | last post by:
Hi All I am using VB.Net 2003 standard edition and would like to put my common library into a dll. Reading some books on the subject this seems possible but it looks like the option does not...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.