Problem with Dynamic Images in WebConrols

Discussion in 'ASP .Net Web Controls' started by Ali Khawaja, Apr 12, 2004.

  1. Ali Khawaja

    Ali Khawaja Guest

    I have trying to build a control: PieChartControl : System.Web.UI.WebControls.WebContro
    in which i am creating a dynamic image based on some data from database

    in the render method of the control, I set the content type of image/jpeg
    this.Context.Response.ContentType = "image/jpeg"
    and then once I am done with creating the image, I save it to the output stream
    bmp.Save(this.Context.Response.OutputStream, ImageFormat.Jpeg)

    I added it to the toolbar, and dropped on my test form, and its shows characters like its not recognizing the content type

    Can anyone please let me know what I am doing wrong

    I'll really appreciate any help
    Thank
    Al
    Ali Khawaja, Apr 12, 2004
    #1
    1. Advertising

  2. You need to call this control from a page that has no content. Basically
    it's empty, no HTML or anything (even one space sent to the browser can mess
    this up). You then call this page as the source of an image tag. For example
    <img src="myimage.aspx"> where myimage.aspx has the control in it. You can't
    embed the binary data into the web page which is why you get the dump of
    characters.

    Hope this helps,
    Mark Fitzpatrick
    Microsoft MVP - FrontPage


    "Ali Khawaja" <> wrote in message
    news:...
    > I have trying to build a control: PieChartControl :

    System.Web.UI.WebControls.WebControl
    > in which i am creating a dynamic image based on some data from database.
    >
    > in the render method of the control, I set the content type of image/jpeg:
    > this.Context.Response.ContentType = "image/jpeg";
    > and then once I am done with creating the image, I save it to the output

    stream:
    > bmp.Save(this.Context.Response.OutputStream, ImageFormat.Jpeg);
    >
    > I added it to the toolbar, and dropped on my test form, and its shows

    characters like its not recognizing the content type.
    >
    > Can anyone please let me know what I am doing wrong.
    >
    > I'll really appreciate any help.
    > Thanks
    > Ali
    >
    >
    >
    >
    Mark Fitzpatrick, Apr 13, 2004
    #2
    1. Advertising

  3. Hi Ali,

    Does Mark's reply makes sense to you? Do you still have any concern?

    Please feel free to let me know, I will help you. Thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.
    Jeffrey Tan[MSFT], Apr 15, 2004
    #3
    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. Guest
    Replies:
    4
    Views:
    890
    Eliyahu Goldin
    Jan 4, 2005
  2. Luis Esteban Valencia Muñoz
    Replies:
    0
    Views:
    768
    Luis Esteban Valencia Muñoz
    Jun 3, 2005
  3. wardemon

    Cache Images vs Static Images

    wardemon, Jun 14, 2007, in forum: ASP .Net
    Replies:
    3
    Views:
    657
    bruce barker
    Jun 14, 2007
  4. EnigmaticSource
    Replies:
    4
    Views:
    825
    EnigmaticSource
    Oct 5, 2007
  5. Keith Hughitt
    Replies:
    6
    Views:
    1,067
Loading...

Share This Page