Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. download a file on a button click

download a file on a button click

Scheduled Pinned Locked Moved ASP.NET
csharphelp
6 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sivaprasad C
    wrote on last edited by
    #1

    Hi friends, Please help in opening a file using c# on a button click... I tried with link button by asigning the resolve url to the file path.. but i couldnt open it...

    Regards, Sivaprasad

    _ P R 3 Replies Last reply
    0
    • S Sivaprasad C

      Hi friends, Please help in opening a file using c# on a button click... I tried with link button by asigning the resolve url to the file path.. but i couldnt open it...

      Regards, Sivaprasad

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #2

      What problem are u getting? Which type of you want to open?

      Best Regards, Apurva Kaushal

      S 1 Reply Last reply
      0
      • S Sivaprasad C

        Hi friends, Please help in opening a file using c# on a button click... I tried with link button by asigning the resolve url to the file path.. but i couldnt open it...

        Regards, Sivaprasad

        P Offline
        P Offline
        psamy
        wrote on last edited by
        #3

        it should be filefield html control will solve your problem.

        1 Reply Last reply
        0
        • S Sivaprasad C

          Hi friends, Please help in opening a file using c# on a button click... I tried with link button by asigning the resolve url to the file path.. but i couldnt open it...

          Regards, Sivaprasad

          R Offline
          R Offline
          Ramasubramaniam
          wrote on last edited by
          #4

          Try this out, We can change the content type to open a file, This code will open document: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + sOrigFilename); Response.AddHeader("Content-Length", oFileInfo.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(sFullFilePath); Response.End(); This will used to open an excel file: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + "c:\\Test\\Test.xls"); Response.AddHeader("Content-Length", oFileInfo.Length.ToString()); Response.ContentType = "application/vnd.ms-excel"; Response.WriteFile("c:\\Test\\Test.xls"); Response.end Ram

          S 1 Reply Last reply
          0
          • _ _AK_

            What problem are u getting? Which type of you want to open?

            Best Regards, Apurva Kaushal

            S Offline
            S Offline
            Sivaprasad C
            wrote on last edited by
            #5

            i want to open a .html file

            Regards, Sivaprasad

            1 Reply Last reply
            0
            • R Ramasubramaniam

              Try this out, We can change the content type to open a file, This code will open document: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + sOrigFilename); Response.AddHeader("Content-Length", oFileInfo.Length.ToString()); Response.ContentType = "application/octet-stream"; Response.WriteFile(sFullFilePath); Response.End(); This will used to open an excel file: Response.Clear(); Response.AddHeader("Content-Disposition", "attachment; filename=" + "c:\\Test\\Test.xls"); Response.AddHeader("Content-Length", oFileInfo.Length.ToString()); Response.ContentType = "application/vnd.ms-excel"; Response.WriteFile("c:\\Test\\Test.xls"); Response.end Ram

              S Offline
              S Offline
              Sivaprasad C
              wrote on last edited by
              #6

              Thanks Ram...U r code will do ..but I want to know the exact content type which will help me to download a .html file I am using Response.ContentType="application/x-zip-compressed" and Response.ContentType="application/x-zip...But in both case i am not able to open it....

              Regards, Sivaprasad

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups