Help with creating a control that generates dynamic image

D

Dave Slinn

I am using various System.Drawing classes to create a graphic at runtime,
with the resulting image varied based on some properties the user may have
set.

Currently I have the graphic being saved to the file system (in a subfolder
of the web app) and then my web control renders a src attrobute to this
graphic file (.png), which works ok at runtime, but this mechanism doesn't
seem to work when viewing the control at design time in Visual Studio. I
did create this control in a Web Control Library project, and referenced the
assembly through my Toolbox, and can now drag and drop instances from there,
but the image displayed on the visual studio designer appears as a broken
graphic (the square with the red X in it).

How can I get the graphic to display properly at design time - can write the
graphic to the Response.OutputStream instead of saving it to the file
system? Any web articles or source code samples pointing me in the write
direction of creating an ASP.NET control that generates an image using the
GDI+ stuff would be most appreciated.

- Dave Slinn
 
S

Steven Cheng[MSFT]

Hi Dave,

Welcome to ASPNET newsgroup.
Regarding on the creating custom image generation webcontrol problem, based
on my experience, it is likely that some of your code accessing some
ASP.NET runtime intrinsic objects which are not available at design-time
when the web control is hosted in IDE's design-view.....

For runtime, the ASP.NET runtime will construct a HttpContext for each
asp.net page request, and we can access thjose intrinsic objects like
Request, Response, Session...... However, all this is not available in
design-time , at that time the control is hosted in IDE's design-time
form..... So we should not put our control's runtime specific code in some
place which will be called at design-time....

Are you putting most of the code in the Control's "Render" method? By
default, if we don't specify a custom ControlDesigner for our webcontrol,
the VS.NET will use the Control's "Render" method to generate the html
being displayed in IDE..... So I think there must have some code in the
render method which cause the error.... You can try simplify the Render
method or comment code step by step to find the break point....

If there're anything unclear or any other question, please feel free to
post here.
Thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)


--------------------
| From: "Dave Slinn" <[email protected]>
| Subject: Help with creating a control that generates dynamic image
| Date: Mon, 12 Dec 2005 21:18:14 -0600
| Lines: 22
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.3790.1830
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.1830
| X-RFC2646: Format=Flowed; Original
| Message-ID: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.buildingcontrols
| NNTP-Posting-Host: online.gms.ca 142.165.52.112
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet.buildingcontrols:14111
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.buildingcontrols
|
| I am using various System.Drawing classes to create a graphic at runtime,
| with the resulting image varied based on some properties the user may
have
| set.
|
| Currently I have the graphic being saved to the file system (in a
subfolder
| of the web app) and then my web control renders a src attrobute to this
| graphic file (.png), which works ok at runtime, but this mechanism
doesn't
| seem to work when viewing the control at design time in Visual Studio. I
| did create this control in a Web Control Library project, and referenced
the
| assembly through my Toolbox, and can now drag and drop instances from
there,
| but the image displayed on the visual studio designer appears as a broken
| graphic (the square with the red X in it).
|
| How can I get the graphic to display properly at design time - can write
the
| graphic to the Response.OutputStream instead of saving it to the file
| system? Any web articles or source code samples pointing me in the write
| direction of creating an ASP.NET control that generates an image using
the
| GDI+ stuff would be most appreciated.
|
| - Dave Slinn
|
|
|
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top