473,387 Members | 1,283 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,387 software developers and data experts.

Updating button text while downloading a file.

Markus
6,050 Expert 4TB
I want the download button to update while a file download is in progress - "Connecting", "Downloading..", etc. But with the code below, it does not update the text. I've read about Application.DoEvents() but also heard that this isn't the best route to take? If it is OK to use Application.DoEvents(), where should I use it?

Expand|Select|Wrap|Line Numbers
  1. button1.Text = "Connecting...";
  2.             Uri URL = new Uri("http://mahcuz.com/projectdownload/ClipboardIP/updatediplist.xml");
  3.             try
  4.             {
  5.                 WebClient Client = new WebClient();
  6.                 button1.Text = "Downloading...";
  7.                 Client.DownloadFile(URL, Application.StartupPath + "/IP.xml");
  8.                 button1.Text = "Finished";
  9.             }
  10.             catch (Exception Ex)
  11.             {
  12.                 button1.Text = "Failed";
  13.             }
Nov 11 '08 #1
2 1088
Plater
7,872 Expert 4TB
I see you took a different route using the IE object instead of HttpWebRequest.

Anyways, in that situation you described, calling button1.Update() (force redraw of buton1) would be more suitable then a full Application.DoEvents().
Nov 11 '08 #2
Markus
6,050 Expert 4TB
I see you took a different route using the IE object instead of HttpWebRequest.

Anyways, in that situation you described, calling button1.Update() (force redraw of buton1) would be more suitable then a full Application.DoEvents().
Yeh, I couldn't find an example of using HttpWebRequest for a file download.

button1.Update() works wonders.

Thanks, Plater.
Nov 11 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Fran Tirimo | last post by:
I am developing a small website using ASP scripts to format data retrieved from an Access database. It will run on a Windows 2003 server supporting FrontPage extensions 2002 hosted by the company...
1
by: Dharmanet | last post by:
Hi, I have a Page1.aspx with a Datagrid which has a link button which spawns a download of a file. one of the columns shows how man times the files were downloaded. The Datagrid is bound to a...
4
by: Edwin Knoppert | last post by:
I have a problem with downloading a PDF by using the response object. A part of it: ..Response.Clear() ..Response.ContentType = sFileType ..Response.AppendHeader("Content-Disposition",...
22
by: Mal Ball | last post by:
I hope I have the right forum for this question. I have an existing Windows application which uses a SQL Server database and stored procedures. I am now developing a web application to use the same...
0
by: Michael Kellogg | last post by:
I have a problem wherein a query that updates a GridView doesn't seem to really stay in sync with a label I have above the GridView. I have a GridView object that I'm updating with information...
4
by: rdemyan via AccessMonster.com | last post by:
My application is calculation intensive and the servers are agonizingly slow. Administrators of my application only update the backends once a month (twice a month max). So, my launching program...
2
by: UKuser | last post by:
Hi Folks, I havent used javascript in ages, and am not the worlds guru, but I'm playing with ajax linking to my database and an updating area. I have an area named display for example which...
15
by: slinky | last post by:
Thanks in advance fo rany help... I have an XML data file (well- formed) that I need to place into my website's app_data folder. I would like to have an .aspx form on my site that simply has two...
3
by: slinky | last post by:
I have an aspx for with a textbox and a button. The goal is to simply have the user type a message, hit the button and it should append to the XML file. I can open the aspx in the browser with no...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...

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.