Help on Response.OutputStream

  • Thread starter Thread starter Joseph
  • Start date Start date
J

Joseph

Hi!
I have this webpage that contains some panels and buttons.
I also want to output an Image to that same page, but when
I save the image to the OutputStream using the Image.Save
(Response.OutputStream) method, the panels and buttons get
overwritten and only the image appears. Is there a way to
preserve the buttons and output the image at the same
time? How do I append to the Response.OutputStream?
Many thanks!
 
Joseph said:
I have this webpage that contains some panels and buttons.
I also want to output an Image to that same page, but when
I save the image to the OutputStream using the Image.Save
(Response.OutputStream) method, the panels and buttons get
overwritten and only the image appears. Is there a way to
preserve the buttons and output the image at the same
time? How do I append to the Response.OutputStream?

You don't want to write the image on the same response - you want to
write an image tag, so that the browser then requests the image. Always
think about things from the browser's point of view.
 
You can amend the output stream by creating a response.filter. You should
really follow Johns suggestion of writing the tag - not the image though -
it might make you think about avoiding response.filters as they are pretty
complex to work with.

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
 
How to I write to html tags?
the only thing i know is to save the image to the outputstream so that
the whole image is outputted to the window. how do i insert tags to the
outputstream?
i would really appreciate your insights.
thanks very much!
 
joseph abanila said:
How to I write to html tags?
the only thing i know is to save the image to the outputstream so that
the whole image is outputted to the window. how do i insert tags to the
outputstream?
i would really appreciate your insights.

You don't insert tags into your output stream. You don't write the
image out at all to start with. On the response which includes your
buttons etc, you have an <img> tag as well as all the buttons. The img
tag will tell the browser which image to fetch.
 
Thanks so much for that!
The window I'm designing dynamically loads linkbuttons that contains
links of page numbers that navigate to images.
Initially the page only shows the page numbers, and when the page
numbers are clicked, the window should load below the page numbers the
selected image page.

I'm planning to add the attribute of the linkbutton as
LinkButton.Attributes.Add("onClick",
"Response.Write(\"<img src=ImagePage.aspx\")");
Will this work?
After the linkbutton is clicked, will that response.write command
preserve the other elements (the linkbuttons, etc)of the html? Won't it
overwrite the html page and show just the image? How do i know just
exactly where in the html page it will output the image?
You've been of great help! Thank you very much.
 
joseph abanila said:
The window I'm designing dynamically loads linkbuttons that contains
links of page numbers that navigate to images.
Initially the page only shows the page numbers, and when the page
numbers are clicked, the window should load below the page numbers the
selected image page.

I'm planning to add the attribute of the linkbutton as
LinkButton.Attributes.Add("onClick",
"Response.Write(\"<img src=ImagePage.aspx\")");
Will this work?
After the linkbutton is clicked, will that response.write command
preserve the other elements (the linkbuttons, etc)of the html? Won't it
overwrite the html page and show just the image? How do i know just
exactly where in the html page it will output the image?
You've been of great help! Thank you very much.

That doesn't sound quite right to me. I suggest you mock it up in HTML
first, and you may want JavaScript to change the image depending on the
click (then it needn't be a server event at all). I suggest asking in
more detail in the ASP.NET group.
 
Back
Top