Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > BOOK: Beginning ASP.NET 2.0 and Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
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
  #2 (permalink)  
Old March 23rd, 2009, 02:42 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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."
===============================================
  #3 (permalink)  
Old March 23rd, 2009, 05:01 PM
Friend of Wrox
Points: 793, Level: 10
Points: 793, Level: 10 Points: 793, Level: 10 Points: 793, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2005
Location: OKC, OK, USA.
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.
  #4 (permalink)  
Old March 23rd, 2009, 07:19 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2005
Location: Ohio, USA
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."
===============================================
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:20 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.