Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 2.0 and Databases
This is the forum to discuss the Wrox book Beginning ASP.NET 2.0 and Databases by John Kauffman, Bradley Millington; ISBN: 9780471781349
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 2.0 and Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 23rd, 2009, 03:15 AM
Authorized User
 
Join Date: Mar 2009
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy messagebox on file download

I am new to ASP.net and I am designing the website is ASP.NET c#

My query:
I would like to get the pop up message box after clicking on the hyperlink while downloading the file that shows whether the file should be opened, saved or cancelled and the file size, duration for file download etc.

Pl. let me know the answer of this bit fast.

Thanking you in advance.

Apurva
 
Old March 23rd, 2009, 02:42 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

The implementation will vary but the process is the same: use a JavaScript confirmation box.

So you might do something like this:

javascript Code:
function GoToDownload()
{
 
   if(confirm('Do you want to download this file?'))
   {
       document.location = 'file.exe';
       return true;
   }
   else
      return false;
 
}

then the html:

<a href='#' onClick="return GoToDownload();">Download File</a>

If i were doing this in a Server control like a button I would probably do something like:

btn.Attributes.Add("onClick", "return confirm('Do you want to download this file?')");

So then when the user clicks on my button they will see the confirmation box and if they click OK the buttons Serverside event is triggered otherwise nothing happens.

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================
 
Old March 23rd, 2009, 05:01 PM
Friend of Wrox
 
Join Date: May 2005
Posts: 227
Thanks: 1
Thanked 7 Times in 7 Posts
Default messagebox on file download

hmmmm......dparsons, I thought apurva was wanting to duplicate the small page that pops up when a customer request, by clicking the download hyperlink. Did I not interpret that correctly?

peace95
__________________
Disclaimer: The above comments are solely the opinion of one person and not to be construed as a directive or an incentive to commit fraudulent acts.
 
Old March 23rd, 2009, 07:19 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Ahhh, my mistake. Thats what i get for reading over a post to quickly! After carefully re-reading I assume you are probably linking to a file that the browser understand (pdf, jpg, xls, etc) and, instead of downloading the file, it is opening it directly. Am I right? If this is the case you will need to write a bit of custom code:

csharp Code:
Response.ContentType = "image/jpeg";
Response.AppendHeader("Content-Disposition","attachment; filename=somejpeg.jpg");
Response.TransmitFile( Server.MapPath("~/somejpeg.jpg") );
Response.End();

You will obviously need to modify this for your purposes but take care to modify the ContentType property so that it matches the type of file you are sending. You can find a fairly good list in the last post of this thread: http://www.daniweb.com/forums/thread38650.html

hth.
-Doug
__________________
===============================================
Doug Parsons
Wrox online library: Wrox Books 24 x 7
Did someone here help you? Click on their post!
"Easy is the path to wisdom for those not blinded by themselves."
===============================================





Similar Threads
Thread Thread Starter Forum Replies Last Post
File Download. rupen ASP.NET 1.x and 2.0 Application Design 4 February 23rd, 2008 08:43 AM
Download File Muhammad Zeeshan ASP.NET 2.0 Professional 0 October 24th, 2007 12:51 AM
Detecting a file download johnnycorpse Classic ASP Basics 1 February 10th, 2007 04:17 PM
Smaller download/single download file available jminatel BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 0 November 21st, 2005 11:10 AM
Force A File To Download harpua Classic ASP Basics 6 July 26th, 2004 01:06 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.