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. Forcing "Save Taget As" dialog when clicking a link

Forcing "Save Taget As" dialog when clicking a link

Scheduled Pinned Locked Moved Web Development
htmldatabasexml
5 Posts 2 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.
  • W Offline
    W Offline
    Wolfram Steinke
    wrote on last edited by
    #1

    I haven written modules that generates a series XML files and a report in a number of HTML files which include and index etc. What I am having difficulty with is that we would like to be able to click on the name of one of the XML files in the report and get the browser to pop up the Save As dialog, so that it can be copied to a location other than the default. This must be possible. I just haven't found out how as yet. Happy programming!!

    M 1 Reply Last reply
    0
    • W Wolfram Steinke

      I haven written modules that generates a series XML files and a report in a number of HTML files which include and index etc. What I am having difficulty with is that we would like to be able to click on the name of one of the XML files in the report and get the browser to pop up the Save As dialog, so that it can be copied to a location other than the default. This must be possible. I just haven't found out how as yet. Happy programming!!

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      Hi there, The extension .xml is a known type, so the browser by default will open it when the user clicks on the link pointing to the file. If you want to force the File Download dialog box, you may consider using the Content-Disposition header field. Instead of using the anchor, you basically use a seperate web page which is responsible for reading the content file of the xml and write out to the Reponse object, and you need to add the Content-Disposition field to the header of the response. With this field, you can suggest a filename which is displayed in the File Download dialog box.

      W 2 Replies Last reply
      0
      • M minhpc_bk

        Hi there, The extension .xml is a known type, so the browser by default will open it when the user clicks on the link pointing to the file. If you want to force the File Download dialog box, you may consider using the Content-Disposition header field. Instead of using the anchor, you basically use a seperate web page which is responsible for reading the content file of the xml and write out to the Reponse object, and you need to add the Content-Disposition field to the header of the response. With this field, you can suggest a filename which is displayed in the File Download dialog box.

        W Offline
        W Offline
        Wolfram Steinke
        wrote on last edited by
        #3

        Thanks for you're suggestion. I'll try it out. Incidentally the file I generate does not use the .xml extension. It doesn't seem to matter what the extension is, for IE anyway, the browser checks that the file contains displable text so it displays it. Happy programming!!

        1 Reply Last reply
        0
        • M minhpc_bk

          Hi there, The extension .xml is a known type, so the browser by default will open it when the user clicks on the link pointing to the file. If you want to force the File Download dialog box, you may consider using the Content-Disposition header field. Instead of using the anchor, you basically use a seperate web page which is responsible for reading the content file of the xml and write out to the Reponse object, and you need to add the Content-Disposition field to the header of the response. With this field, you can suggest a filename which is displayed in the File Download dialog box.

          W Offline
          W Offline
          Wolfram Steinke
          wrote on last edited by
          #4

          I must be doing something wrong as I can't get it to work. Could you suggest how the HTML is supposed to look. This is not being done via a server. Happy programming!!

          M 1 Reply Last reply
          0
          • W Wolfram Steinke

            I must be doing something wrong as I can't get it to work. Could you suggest how the HTML is supposed to look. This is not being done via a server. Happy programming!!

            M Offline
            M Offline
            minhpc_bk
            wrote on last edited by
            #5

            The markup in the html file looks something like:

            <a href="Download.aspx?filename=foo.xml" >foo.xml</a>

            So you specify the web page in the href attribute of the anchor element instead of the foo.xml. Also, you might want to add the name of the xml file to query string so that it can be used later in the web page for reading the file content. In the web page, you programmatically add the Content-Disposition field to the header of the reponse. In addition, you can also statically add the Content-Disposition field to the header in the IIS-snapin (Here, I assume you are using the IIS as your web server).

            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