DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2005
    Posts
    105

    Working with buttons

    I have a newbie question ...

    I have a button on a website that needs to trigger a download when it's clicked. If I know the location of the file to be downloaded, how can I make that happen in the HTLM code.

    Thanks!

  2. #2
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    Since this is the ASP.NET forum, I assume you're looking for server-side ASP.NET code? You can put code like the following in the button's server-side Click event procedure:
    Code:
    Response.ContentType = "application\octet-stream"
    Dim FileName As String = "d:\path\filename.ext"
    Dim fs As New IO.FileStream(FileName, IO.FileMode.Open)
    Response.Write(fs.Length.ToString() & "#")
    fs.Close()
    Response.WriteFile(FileName)
    Response.Flush()
    Response.End()
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

Similar Threads

  1. buttons with templates and formview???
    By dave.potter@hol in forum .NET
    Replies: 2
    Last Post: 01-30-2006, 11:54 AM
  2. Formview - Templates - Buttons ???
    By dave.potter@hol in forum ASP.NET
    Replies: 0
    Last Post: 10-07-2005, 06:10 PM
  3. Dynamic Buttons disappearing
    By spudmasher in forum ASP.NET
    Replies: 3
    Last Post: 07-03-2005, 11:59 PM
  4. Working with Buttons
    By ej in forum Java
    Replies: 1
    Last Post: 11-02-2002, 07:58 AM
  5. Java Newbie: Working with GUI Windows
    By Scott in forum Java
    Replies: 0
    Last Post: 11-30-2000, 10:08 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links