473,382 Members | 1,622 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Output Dynamic Graphic from Webcontrol

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

Jun 27 '08 #1
4 1502
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

On May 26, 12:49*am, "Jonathan Wood" <jw...@softcircuits.comwrote:
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
Jun 27 '08 #2
On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
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
Jun 27 '08 #3
Wow. New stuff for me. Will take me a while to figure it all out but looks
interesting. Thanks!

Jonathan

"marss" <ma******@gmail.comwrote in message
news:2d**********************************@r66g2000 hsg.googlegroups.com...
On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
>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
Jun 27 '08 #4
On May 27, 10:09 am, "Jonathan Wood" <jw...@softcircuits.comwrote:
Wow. New stuff for me. Will take me a while to figure it all out but looks
interesting. Thanks!

Jonathan

"marss" <marss...@gmail.comwrote in message

news:2d**********************************@r66g2000 hsg.googlegroups.com...
On May 25, 7:49 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
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
Hi

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

http://www.sitepoint.com/article/gen...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
Jun 27 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Tim Streater | last post by:
I want to generate a web page using PHP, and in the middle generate a graphic I read from another server. So the graphic is in $picture. So I can either write $picture to a temp file and then use...
2
by: salvo | last post by:
Hi, I made a little program in C++, which initially displayed its data to the standard output with the cout object. Now that I added a little graphic interface with gtk+, I'd like to keep the...
2
by: ViperDK | last post by:
What is the best way for that? I store all Data in the original form in the Database. To prevent output fields (especially the fields everyone can use) to do bad things like killing the...
3
by: kw | last post by:
Page X loads WebControl Y which loads WebControl Z. WebControlZ defines a button: protected System.Web.UI.WebControls.LinkButton SearchByAssr; here comes the problem: private void...
2
by: Michael | last post by:
Need some help trying to read values from web controls - specifically *finding* the controls (like a drop down list) - that are added dynamically added within an asp:panel control. The page...
0
by: Charlie | last post by:
When a property of a WebControl is changed at design-time in the property window, the Render method for that WebControls runs. When the property of one WebControl cascades to another WebControl,...
2
by: Lloyd Sheen | last post by:
Ok I have created a small testbed site for testing and I am have a problem with the terms Usercontrol, Webcontrol, etc. What I need to do in the long run is have a page using AJAX and having...
10
hoist1138
by: hoist1138 | last post by:
Thanks to anyone who may be able to steer me in the right direction :) Interesting that this works fine in All Browsers BUT Internet Explorer. fairly simple goal...... get a "src" img element...
1
by: Andre | last post by:
Hi. There is a way, that I can create a dynamic ID in a WebControl. This doesn´t work, but, looks like what I want: <asp:Button ID="btnAdd<%="1"%>" runat="server" Text="Add Resposta"...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.