Home All Groups Group Topic Archive Search About
Author
8 Sep 2006 11:40 AM
Flurry
Hello

I've got a problem and I'm not getting much help trying to resolve it.
I've searched google all morning for an answer....

I have the following code:

            Lab1.text = "Your Serial Number is: "
            Lab2.text = serialNo & "-" & serialYY

            Response.Clear()
            Response.AddHeader("Content-Disposition", "attachment;
filename=" & fname)
            Response.ContentType = "txt, doc, jpg"
            Response.WriteFile(path)

which is supposed to output a serial number in two labels and then
download a file. The problem is that when I put the code to download
the file, the serial number is not displayed on the page.

To recap and make sure everything is clear. Without the download code
the labels get set correctly. When I put the download code in, the file
downloads correctly but the labels are never set.

Can someone explain what is going on????

Many thanks...

Author
8 Sep 2006 11:53 AM
Karl Seguin [MVP]
It's a single response...you can't both stream normal html and biarny data
on it. It's a basic http/web thing. It's why if you go visit an image in
your browser, say, http://www.google.com/intl/en/images/logo.gif you'll
never see plain text as well as the image.

One solution might be to load the page, display your 2 labels, and use a
javascript to redirect to downloadSomeFile.aspx   downloadSomeFile.aspx
would let the user download the file, while the page would stay where it is
since no new html stream was received.

Karl

Show quoteHide quote
"Flurry" <cj406***@stmail.staffs.ac.uk> wrote in message
news:1157715622.155464.218000@m79g2000cwm.googlegroups.com...
> Hello
>
> I've got a problem and I'm not getting much help trying to resolve it.
> I've searched google all morning for an answer....
>
> I have the following code:
>
>            Lab1.text = "Your Serial Number is: "
>            Lab2.text = serialNo & "-" & serialYY
>
>            Response.Clear()
>            Response.AddHeader("Content-Disposition", "attachment;
> filename=" & fname)
>            Response.ContentType = "txt, doc, jpg"
>            Response.WriteFile(path)
>
> which is supposed to output a serial number in two labels and then
> download a file. The problem is that when I put the code to download
> the file, the serial number is not displayed on the page.
>
> To recap and make sure everything is clear. Without the download code
> the labels get set correctly. When I put the download code in, the file
> downloads correctly but the labels are never set.
>
> Can someone explain what is going on????
>
> Many thanks...
>
Are all your drivers up to date? click for free checkup

Author
8 Sep 2006 12:40 PM
Hans Kesting
>             Response.ContentType = "txt, doc, jpg"

ContentType should be a *MIME type*, like "text/plain",
"application/msword", "image/jpeg", not the file-extension.

See http://www.ltsw.se/knbase/internet/mime.htp

Hans Kesting

Bookmark and Share