Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / May 2008

Tip: Looking for answers? Try searching our database.

Output Dynamic Graphic from Webcontrol

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonathan Wood - 25 May 2008 17:49 GMT
I've figured out how to create an image on the fly on my Website. Once
created, I write the image to the page using code like this:

 Bitmap bm = [...]
 [...]
 Response.ContentType = "image/jpeg";
 bm.Save(Response.OutputStream, ImageFormat.Jpeg);

The code I have does indeed display the graphic, but the page shows nothing
else. I need to write the image to a location within my Web page.

My preference would be to create a Web control, that I can embed in the
page, and then write the image from the control. However, the control's
Render handler provides an HtmlTextWriter argument, which does not have an
OutputStream property.

How can I output the graphic as the control's output?

Thanks.

Jonathan
nick chan - 26 May 2008 07:09 GMT
your control needs to output an Image location as a string
then, another page will actually load the image
u can either create another aspx page, or read up about ashx/axd

> I've figured out how to create an image on the fly on my Website. Once
> created, I write the image to the page using code like this:
[quoted text clipped - 17 lines]
>
> Jonathan
marss - 26 May 2008 08:04 GMT
> How can I output the graphic as the control's output?

1. Add new Generic Handler to the project. Name it, for example,
"Handler1".

2. Put the code for image creation inside of ProcessRequest method.
void ProcessRequest(HttpContext context)
{
  //create image
 Bitmap bm = [...]
 [...]
 context.Response.ContentType = "image/jpeg";
 bm.Save(context.Response.OutputStream, ImageFormat.Jpeg);
}

3.Use it as an ordinary image url
<asp:Image ImageUrl="~/Handler1.ashx" ...

Regards,
Mykola
http://marss.co.ua - Casual ideas for web development
Jonathan Wood - 27 May 2008 05:09 GMT
Wow. New stuff for me. Will take me a while to figure it all out but looks
interesting. Thanks!

Jonathan

>> How can I output the graphic as the control's output?
>
[quoted text clipped - 17 lines]
> Mykola
> http://marss.co.ua - Casual ideas for web development
Munna - 27 May 2008 06:29 GMT
> Wow. New stuff for me. Will take me a while to figure it all out but looks
> interesting. Thanks!
[quoted text clipped - 22 lines]
> > Mykola
> >http://marss.co.ua- Casual ideas for web development

Hi

here is few links about dynamic image display that will help you kick
start

http://www.sitepoint.com/article/generating-asp-net-images-fly
http://aspalliance.com/articleViewer.aspx?aId=141&pId=

Best of luck
Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.