write response.outputstream into a control

Discussion in 'ASP .Net' started by Victor, May 8, 2007.

  1. Victor

    Victor Guest

    Hi Guys
    I have a server-side div control inside my aspx page. I also have another
    Memory image object (like Bitmap image = new Bitmap(FileName)). The
    objective I want to achieve is adding this image object into the div
    control. I tried to use Bitmap.save(Stream stream, ImageFormat format)
    method. But I found out if I did so, it will overwrite my rest of page.
    Insteading of displaying the page properly, It only displays one image.
    Can anyone help me on this? Is this possible to write outputstream into one
    control?

    cheers
    Victor
    Victor, May 8, 2007
    #1
    1. Advertising

  2. Victor

    robert112 Guest

    On May 8, 12:19 pm, "Victor" <> wrote:
    > Hi Guys
    > I have a server-side div control inside my aspx page. I also have another
    > Memory image object (like Bitmap image = new Bitmap(FileName)). The
    > objective I want to achieve is adding this image object into the div
    > control. I tried to use Bitmap.save(Stream stream, ImageFormat format)
    > method. But I found out if I did so, it will overwrite my rest of page.
    > Insteading of displaying the page properly, It only displays one image.
    > Can anyone help me on this? Is this possible to write outputstream into one
    > control?
    >
    > cheers
    > Victor


    I'm not sure I understand correctly but try wrapping that div in a
    panel and add the image object to the panel.

    so something like
    <html>
    <div id="SomeDiv"><asp:panel id="foo" runat="server"></panel></div>
    </html>

    then in the code behind: foo.add(imageObject)
    robert112, May 8, 2007
    #2
    1. Advertising

  3. Hi Victor,

    Yes by writing out to the Response stream using the binary image data, the
    response at client-side will be the image only.

    To embed an image in some other element, you will need an <img> tag at
    client-side. You can use an server control <asp:Image> inside your div tag.
    You will need another webform to generate the image using Bitmap and
    Response stream. Then you can point the Image control's ImageUrl property
    to this webform:

    <div>
    <asp:Image runat="server" ID="image1"
    ImageUrl="GetImage.aspx?name=foo" />
    </div>


    In the GetImage.aspx, you can check the QueryString and use different image
    file accordingly.

    Hope this helps.

    Regards,
    Walter Wang (, remove 'online.')
    Microsoft Online Community Support

    ==================================================
    When responding to posts, please "Reply to Group" via your newsreader so
    that others may learn and benefit from your issue.
    ==================================================

    This posting is provided "AS IS" with no warranties, and confers no rights.
    Walter Wang [MSFT], May 8, 2007
    #3
  4. Victor

    Victor Guest

    OhOh, that works
    thanks a lot Walter~~~:)
    "Walter Wang [MSFT]" <> wrote in message
    news:...
    > Hi Victor,
    >
    > Yes by writing out to the Response stream using the binary image data, the
    > response at client-side will be the image only.
    >
    > To embed an image in some other element, you will need an <img> tag at
    > client-side. You can use an server control <asp:Image> inside your div
    > tag.
    > You will need another webform to generate the image using Bitmap and
    > Response stream. Then you can point the Image control's ImageUrl property
    > to this webform:
    >
    > <div>
    > <asp:Image runat="server" ID="image1"
    > ImageUrl="GetImage.aspx?name=foo" />
    > </div>
    >
    >
    > In the GetImage.aspx, you can check the QueryString and use different
    > image
    > file accordingly.
    >
    > Hope this helps.
    >
    > Regards,
    > Walter Wang (, remove 'online.')
    > Microsoft Online Community Support
    >
    > ==================================================
    > When responding to posts, please "Reply to Group" via your newsreader so
    > that others may learn and benefit from your issue.
    > ==================================================
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    Victor, May 9, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ryan Hartman

    large files via Response.OutputStream.Write

    Ryan Hartman, Nov 4, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    7,286
    Ryan Hartman
    Nov 11, 2003
  2. Richard
    Replies:
    3
    Views:
    3,563
    Craig Deelsnyder
    Jan 2, 2004
  3. André
    Replies:
    3
    Views:
    1,884
    André
    Dec 1, 2006
  4. Replies:
    2
    Views:
    3,566
  5. AAaron123
    Replies:
    4
    Views:
    2,346
    AAaron123
    Nov 13, 2008
Loading...

Share This Page