Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Load Image Dynamically

Reply
Thread Tools

Load Image Dynamically

 
 
Mr.Cyber
Guest
Posts: n/a
 
      11-27-2005
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!!!

 
Reply With Quote
 
 
 
 
Gokhan Altinoren
Guest
Posts: n/a
 
      11-27-2005
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!!!
>




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
help with design - reload image on image load; avoid infinite loop lawpoop Javascript 17 06-22-2009 06:59 PM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-05-2005 12:04 AM
Load User Control Dynamically, Cast object dynamically =?Utf-8?B?UmV6YSBOYWJp?= ASP .Net 1 03-04-2005 07:57 PM
wx.Image: Couldn't add an image to the image list. Laszlo Zsolt Nagy Python 1 01-26-2005 09:55 PM
[image] Optimize image load Blaise Java 3 10-07-2003 08:01 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57