Load Image Dynamically

Discussion in 'ASP .Net Building Controls' started by Mr.Cyber, Nov 27, 2005.

  1. Mr.Cyber

    Mr.Cyber Guest

    Hi, brothers :)

    I'm rather novice in this area. I mean web programming and control building
    and though.

    I create UserControl:
    public class ucParsedPNG : System.Web.UI.UserControl
    {
    ... blah-blah-blah ...

    }

    My UserControl has to contain image and this one should be loaded
    dynamically from a stream from C# code.

    I have two files:
    ucParsedPNG.ascx
    ucParsedPNG.ascx.cs

    I'v heard that in tag <IMG> in attribute <SRC> I can specify some script.
    But all this I could do if I would use HTML. Now I'm trying to write in C#.
    What exactly should I do now to achieve needed result.

    All kind of help, hints, links and explanation will be highly appreciated!!!

    A lot of thanks in advance!!!
    Mr.Cyber, Nov 27, 2005
    #1
    1. Advertising

  2. Hello Mr.Cyber,

    A user control can manipulate the page's html output, add some tags etc.,
    but cannot attach another resource other than pure html. In fact, HTML is
    a text only world, where you define layout, content and resource references,
    not the resource itself.

    Having said that, your control can tell the page to look somewhere for a
    specific image but it can't just output the image with the page.

    Write another ascx or aspx, make them accept a parameter or two to get the
    stream you are looking for, have it response the image into the response
    stream, and add a reference to them in ucParsedPNG's output.

    Something like <img src="foo.aspx?imgid=1">

    ....and somewhere in foo.aspx:

    this.Response.Clear();
    this.Response.ContentType = "image/png"; // not sure about the mime type
    for png
    imageFromStream.Save(this.Response.OutputStream, _type);
    //...dispose as necessary

    I guess it should be something like this. Hope this helps.

    Gokhan Altinoren
    gokhan[RMV_this][at]altinoren[also_RMV_this][dot]com
    http://altinoren.com

    > Hi, brothers :)
    >
    > I'm rather novice in this area. I mean web programming and control
    > building and though.
    >
    > I create UserControl:
    > public class ucParsedPNG : System.Web.UI.UserControl
    > {
    > ... blah-blah-blah ...
    > }
    >
    > My UserControl has to contain image and this one should be loaded
    > dynamically from a stream from C# code.
    >
    > I have two files:
    > ucParsedPNG.ascx
    > ucParsedPNG.ascx.cs
    > I'v heard that in tag <IMG> in attribute <SRC> I can specify some
    > script. But all this I could do if I would use HTML. Now I'm trying to
    > write in C#. What exactly should I do now to achieve needed result.
    >
    > All kind of help, hints, links and explanation will be highly
    > appreciated!!!
    >
    > A lot of thanks in advance!!!
    >
    Gokhan Altinoren, Nov 27, 2005
    #2
    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. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,697
    Matt Berther
    Mar 5, 2005
  2. =?Utf-8?B?UmV6YSBOYWJp?=

    Load User Control Dynamically, Cast object dynamically

    =?Utf-8?B?UmV6YSBOYWJp?=, Mar 4, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    6,338
    Scott Allen
    Mar 4, 2005
  3. Blaise

    [image] Optimize image load

    Blaise, Oct 6, 2003, in forum: Java
    Replies:
    3
    Views:
    661
    Blaise
    Oct 7, 2003
  4. Laszlo Zsolt Nagy
    Replies:
    1
    Views:
    1,248
    Kartic
    Jan 26, 2005
  5. lawpoop
    Replies:
    17
    Views:
    739
    Thomas 'PointedEars' Lahn
    Jun 22, 2009
Loading...

Share This Page