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. Open Documents from List Box

Open Documents from List Box

Scheduled Pinned Locked Moved ASP.NET
questioncsharpjson
7 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.
  • P Offline
    P Offline
    Paul Unsworth
    wrote on last edited by
    #1

    Hi Guys I have a web app, and in this web app I have a list box. This list box displays file names of word documents that relate to the project which is displayed in the rest of the app. I have the File names displayed, but the value of the list box is set to the full file path. My question is, how can I open the documents when a user selects a document and clicks on the "Open Document" button? I used a ListBox because I'm quite tight on space... Thank in advance :) edit: I'm using C#

    oooo, the Jedi's will feel this one....

    A A 2 Replies Last reply
    0
    • P Paul Unsworth

      Hi Guys I have a web app, and in this web app I have a list box. This list box displays file names of word documents that relate to the project which is displayed in the rest of the app. I have the File names displayed, but the value of the list box is set to the full file path. My question is, how can I open the documents when a user selects a document and clicks on the "Open Document" button? I used a ListBox because I'm quite tight on space... Thank in advance :) edit: I'm using C#

      oooo, the Jedi's will feel this one....

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Paul Unsworth wrote:

      My question is, how can I open the documents when a user selects a document and clicks on the "Open Document" button?

      You can initiate the File Save As Dialog box on button Click.

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

      P 1 Reply Last reply
      0
      • A Abhijit Jana

        Paul Unsworth wrote:

        My question is, how can I open the documents when a user selects a document and clicks on the "Open Document" button?

        You can initiate the File Save As Dialog box on button Click.

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you.

        P Offline
        P Offline
        Paul Unsworth
        wrote on last edited by
        #3

        How do you do that? I've tried looking on google, and all I can find are Response.TransmitFile() or Response.WriteFile() which just write the file into the browser just before the page starts. I was playing around with creating a hyperlink object, and setting the navigate url to the files url, but I cannot find a way to activate it. I would have used hyperlinks if space and neatness were not so much of an issue...

        oooo, the Jedi's will feel this one....

        C 1 Reply Last reply
        0
        • P Paul Unsworth

          How do you do that? I've tried looking on google, and all I can find are Response.TransmitFile() or Response.WriteFile() which just write the file into the browser just before the page starts. I was playing around with creating a hyperlink object, and setting the navigate url to the files url, but I cannot find a way to activate it. I would have used hyperlinks if space and neatness were not so much of an issue...

          oooo, the Jedi's will feel this one....

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          Paul Unsworth wrote:

          Response.WriteFile()

          That's it, just set the content type first so that the browser knows it's a download, or perhaps a file to be opened in the browser.

          Paul Unsworth wrote:

          I was playing around with creating a hyperlink object, and setting the navigate url to the files url, but I cannot find a way to activate it.

          How do you mean, activate ?

          Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

          P 1 Reply Last reply
          0
          • P Paul Unsworth

            Hi Guys I have a web app, and in this web app I have a list box. This list box displays file names of word documents that relate to the project which is displayed in the rest of the app. I have the File names displayed, but the value of the list box is set to the full file path. My question is, how can I open the documents when a user selects a document and clicks on the "Open Document" button? I used a ListBox because I'm quite tight on space... Thank in advance :) edit: I'm using C#

            oooo, the Jedi's will feel this one....

            A Offline
            A Offline
            Abhishek Sur
            wrote on last edited by
            #5

            Use this when user clicks the button to download the file :

            Response.Clear();
            Response.ContentType="application/word";
            Response.AppendHeader("Content-Disposition","attachment; filename=yourfilename.doc");
            Response.TransmitFile(serverfilepath);
            Response.End();

            Cheers. :rose:

            Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


            My Latest Articles-->** Simplify Code Using NDepend
            Basics of Bing Search API using .NET
            Microsoft Bing MAP using Javascript

            P 1 Reply Last reply
            0
            • C Christian Graus

              Paul Unsworth wrote:

              Response.WriteFile()

              That's it, just set the content type first so that the browser knows it's a download, or perhaps a file to be opened in the browser.

              Paul Unsworth wrote:

              I was playing around with creating a hyperlink object, and setting the navigate url to the files url, but I cannot find a way to activate it.

              How do you mean, activate ?

              Christian Graus Driven to the arms of OSX by Vista. Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.

              P Offline
              P Offline
              Paul Unsworth
              wrote on last edited by
              #6

              By activate, I mean somehow make it think it has been clicked. I was just experimenting with that one. I suppose I was just trying to cheat. :-O Thank you for your reply. :)

              oooo, the Jedi's will feel this one....

              1 Reply Last reply
              0
              • A Abhishek Sur

                Use this when user clicks the button to download the file :

                Response.Clear();
                Response.ContentType="application/word";
                Response.AppendHeader("Content-Disposition","attachment; filename=yourfilename.doc");
                Response.TransmitFile(serverfilepath);
                Response.End();

                Cheers. :rose:

                Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.


                My Latest Articles-->** Simplify Code Using NDepend
                Basics of Bing Search API using .NET
                Microsoft Bing MAP using Javascript

                P Offline
                P Offline
                Paul Unsworth
                wrote on last edited by
                #7

                That was the exact ticket! Thank you. :-D

                oooo, the Jedi's will feel this one....

                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