Help with creating a control that generates dynamic image

Discussion in 'ASP .Net Building Controls' started by Dave Slinn, Dec 13, 2005.

  1. Dave Slinn

    Dave Slinn Guest

    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
     
    Dave Slinn, Dec 13, 2005
    #1
    1. Advertising

  2. 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" <>
    | 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: <Obc3bP5$>
    | 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
    |
    |
    |
     
    Steven Cheng[MSFT], Dec 13, 2005
    #2
    1. Advertising

  3. On Mon, 12 Dec 2005 21:18:14 -0600, Dave Slinn wrote:

    > 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.
    > 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.



    http://www.antoniob.com/projects/PStreamImage.aspx



    --
    http://www.antoniob.com/
    remove antispam XremoveX from e-mail !
     
    Antonio Bakula, Dec 15, 2005
    #3
    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. Timbo
    Replies:
    1
    Views:
    5,961
    bruce barker \(sqlwork.com\)
    May 5, 2006
  2. Vaibhav Shah
    Replies:
    1
    Views:
    486
    bruce barker \(sqlwork.com\)
    Sep 6, 2006
  3. Mayank Kaushik

    Doubt about how a linker generates a memory image

    Mayank Kaushik, Feb 18, 2005, in forum: C Programming
    Replies:
    3
    Views:
    316
    Bansidhar
    Feb 18, 2005
  4. computer_guy
    Replies:
    4
    Views:
    475
    computer_guy
    Jul 21, 2007
  5. Kai-Uwe Bux
    Replies:
    1
    Views:
    366
    Kai-Uwe Bux
    Nov 29, 2008
Loading...

Share This Page