Professional Web Applications Themes

Save or Open - ASP.NET General

Hi, I generate a report in a comma delimited file and give it a name like MyReport.csv . I then set a Hyperlink control to point tp the file HyperLink1.text = "Download" Hyperlink1.NavigateUrl = "MyReport.csv" When the user clicks the HyperLink I would always like to see the dialog come up that asks if you want to 'Open' the file or 'Save' the file to disk. I get mixed results. If the client has Excel installed then this dialog does not come up and IE pops the file into a spread sheet. If Excel is not installed then IE pops ...

  1. #1

    Default Save or Open

    Hi,

    I generate a report in a comma delimited file and give it
    a name like MyReport.csv . I then set a Hyperlink
    control to point tp the file

    HyperLink1.text = "Download"
    Hyperlink1.NavigateUrl = "MyReport.csv"

    When the user clicks the HyperLink I would always like to
    see the dialog come up that asks if you want to 'Open' the
    file or 'Save' the file to disk.

    I get mixed results. If the client has Excel installed
    then this dialog does not come up and IE pops the file
    into a spread sheet. If Excel is not installed then IE
    pops the file up in a text window (same thing happens if I
    delete the csv from the folder options).

    If I change the file extension to something strange
    like .xyz123 then it always comes up with the dialog but
    I want the user to have the option to save the file as
    csv.

    Anyway, is there some way to force this to always come up
    with the Open or Save dialog?

    Tks,
    JOhn
    John Guest

  2. #2

    Default Re: Save or Open

    Not that i know of. Users can force the dialog manually by right clicking /
    Save Target As. Either that or just zip the file.
    -Trevor


    "John" <jcronlinedashgroup.com> wrote in message
    news:010901c33b2c$46cc9bc0$a101280aphx.gbl...
    > Hi,
    >
    > I generate a report in a comma delimited file and give it
    > a name like MyReport.csv . I then set a Hyperlink
    > control to point tp the file
    >
    > HyperLink1.text = "Download"
    > Hyperlink1.NavigateUrl = "MyReport.csv"
    >
    > When the user clicks the HyperLink I would always like to
    > see the dialog come up that asks if you want to 'Open' the
    > file or 'Save' the file to disk.
    >
    > I get mixed results. If the client has Excel installed
    > then this dialog does not come up and IE pops the file
    > into a spread sheet. If Excel is not installed then IE
    > pops the file up in a text window (same thing happens if I
    > delete the csv from the folder options).
    >
    > If I change the file extension to something strange
    > like .xyz123 then it always comes up with the dialog but
    > I want the user to have the option to save the file as
    > csv.
    >
    > Anyway, is there some way to force this to always come up
    > with the Open or Save dialog?
    >
    > Tks,
    > JOhn

    Trevor Hartman Guest

  3. #3

    Default Re: Save or Open

    Try creating an ASPX page that opens and reads the file, and then sets the
    Response.ContentType property to "application/octet-stream" and then
    Response.BinaryWrite()s the file to the output stream. Then you can link to
    this file, and you should get the desired effect.

    HTH,

    Kevin Spencer
    Microsoft FrontPage MVP
    Internet Developer
    [url]http://www.takempis.com[/url]
    Big things are made up of
    lots of Little things.

    "John" <jcronlinedashgroup.com> wrote in message
    news:010901c33b2c$46cc9bc0$a101280aphx.gbl...
    > Hi,
    >
    > I generate a report in a comma delimited file and give it
    > a name like MyReport.csv . I then set a Hyperlink
    > control to point tp the file
    >
    > HyperLink1.text = "Download"
    > Hyperlink1.NavigateUrl = "MyReport.csv"
    >
    > When the user clicks the HyperLink I would always like to
    > see the dialog come up that asks if you want to 'Open' the
    > file or 'Save' the file to disk.
    >
    > I get mixed results. If the client has Excel installed
    > then this dialog does not come up and IE pops the file
    > into a spread sheet. If Excel is not installed then IE
    > pops the file up in a text window (same thing happens if I
    > delete the csv from the folder options).
    >
    > If I change the file extension to something strange
    > like .xyz123 then it always comes up with the dialog but
    > I want the user to have the option to save the file as
    > csv.
    >
    > Anyway, is there some way to force this to always come up
    > with the Open or Save dialog?
    >
    > Tks,
    > JOhn

    Kevin Spencer Guest

  4. #4

    Default Re: Save or Open

    Thanks, this seems to work. One small problem, when you
    clict 'Open' it repeats the dialog and you need to click
    Open a second time. But, much better than before.
    >-----Original Message-----
    >It is a tricky problem, most browsers try to do whatever
    they can depending
    >on the type of file.
    >However, it is possible to override the headers of the
    output to convince
    >the browser that it should try and do something else with
    it.
    >
    >Instead of just a hyperlink url, generate a control
    (button / imagebutton
    >etc) with an event / postback
    >Then within the server side code (OnClick) use the
    following with the
    >Response object.
    >
    >Response.AppendHeader( "content-disposition", "attachment;
    >filename=MyReport.csv");
    > Response.WriteFile(Server.MapPath
    ("MyReport.csv"));
    > Response.End();
    >
    >Regards,
    >Robin
    >
    >"John" <jcronlinedashgroup.com> wrote in message
    >news:010901c33b2c$46cc9bc0$a101280aphx.gbl...
    >> Hi,
    >>
    >> I generate a report in a comma delimited file and give
    it
    >> a name like MyReport.csv . I then set a Hyperlink
    >> control to point tp the file
    >>
    >> HyperLink1.text = "Download"
    >> Hyperlink1.NavigateUrl = "MyReport.csv"
    >>
    >> When the user clicks the HyperLink I would always like
    to
    >> see the dialog come up that asks if you want to 'Open'
    the
    >> file or 'Save' the file to disk.
    >>
    >> I get mixed results. If the client has Excel installed
    >> then this dialog does not come up and IE pops the file
    >> into a spread sheet. If Excel is not installed then IE
    >> pops the file up in a text window (same thing happens
    if I
    >> delete the csv from the folder options).
    >>
    >> If I change the file extension to something strange
    >> like .xyz123 then it always comes up with the dialog
    but
    >> I want the user to have the option to save the file as
    >> csv.
    >>
    >> Anyway, is there some way to force this to always come
    up
    >> with the Open or Save dialog?
    >>
    >> Tks,
    >> JOhn
    >
    >
    >.
    >
    john Guest

  5. #5

    Default Re: Save or Open

    Sorry about blank reply!! Ack, itchy fingers!

    Strange, check that there are no other Response Redirects or Url links as
    part of this control. Also, maybe try clearing the Response object before
    adding the new header and writing the file.

    In general whenever I find I need to force the use to do a save as (as
    below) I usually provide two buttons, one for save, one for open. The save
    forces the dialog and the open just does a response.redirect. That way they
    never have the need to click the Save button and then try and open it.

    "john" <jcronlinedashgroup.com> wrote in message
    news:0c3a01c33b55$e112caf0$a001280aphx.gbl...
    > Thanks, this seems to work. One small problem, when you
    > clict 'Open' it repeats the dialog and you need to click
    > Open a second time. But, much better than before.
    >
    > >-----Original Message-----
    > >It is a tricky problem, most browsers try to do whatever
    > they can depending
    > >on the type of file.
    > >However, it is possible to override the headers of the
    > output to convince
    > >the browser that it should try and do something else with
    > it.
    > >
    > >Instead of just a hyperlink url, generate a control
    > (button / imagebutton
    > >etc) with an event / postback
    > >Then within the server side code (OnClick) use the
    > following with the
    > >Response object.
    > >
    > >Response.AppendHeader( "content-disposition", "attachment;
    > >filename=MyReport.csv");
    > > Response.WriteFile(Server.MapPath
    > ("MyReport.csv"));
    > > Response.End();
    > >
    > >Regards,
    > >Robin
    > >
    > >"John" <jcronlinedashgroup.com> wrote in message
    > >news:010901c33b2c$46cc9bc0$a101280aphx.gbl...
    > >> Hi,
    > >>
    > >> I generate a report in a comma delimited file and give
    > it
    > >> a name like MyReport.csv . I then set a Hyperlink
    > >> control to point tp the file
    > >>
    > >> HyperLink1.text = "Download"
    > >> Hyperlink1.NavigateUrl = "MyReport.csv"
    > >>
    > >> When the user clicks the HyperLink I would always like
    > to
    > >> see the dialog come up that asks if you want to 'Open'
    > the
    > >> file or 'Save' the file to disk.
    > >>
    > >> I get mixed results. If the client has Excel installed
    > >> then this dialog does not come up and IE pops the file
    > >> into a spread sheet. If Excel is not installed then IE
    > >> pops the file up in a text window (same thing happens
    > if I
    > >> delete the csv from the folder options).
    > >>
    > >> If I change the file extension to something strange
    > >> like .xyz123 then it always comes up with the dialog
    > but
    > >> I want the user to have the option to save the file as
    > >> csv.
    > >>
    > >> Anyway, is there some way to force this to always come
    > up
    > >> with the Open or Save dialog?
    > >>
    > >> Tks,
    > >> JOhn
    > >
    > >
    > >.
    > >

    Robin Day Guest

Similar Threads

  1. Save and Open doents
    By Tom_Svensen@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 1
    Last Post: July 6th, 03:43 PM
  2. Open file, make changes, save file, close, re-open, file contents not changed
    By brock@bergdesign.com in forum Adobe Illustrator Macintosh
    Replies: 7
    Last Post: March 7th, 07:29 PM
  3. Force GetUrl to open dialog box "open or save"
    By deliris in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: February 26th, 05:08 PM
  4. Replies: 5
    Last Post: October 6th, 06:08 PM
  5. Replies: 0
    Last Post: October 3rd, 04:05 PM

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
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139