ControlDesigner.OnPaint

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default ControlDesigner.OnPaint

    We have created some dynamic web image controls. At design time we use
    System.Web.UI.Design.ControlDesigner.OnPaint to draw our control directly to
    the design surface. This saves us from having to create temporary images on
    the file system.

    The problem is when our controls are placed inside a template control like
    FormView. The OnPaint method is not called so our controls appear as broken
    images. Any work around for this?

    breeve Guest

  2. Similar Questions and Discussions

    1. ReadWriteControlDesigner or ControlDesigner to be used?
      Hi I am developing a collapsible panel for ASP.NET now I need to provide a visual designer for the control. earlier, I created a designer for...
    2. How do you do a Web ControlDesigner?
      How do you do a ControlDesigner? It seems that the docs are out of date with the namespaces? Using VS 2003, I can not get the snippet from this...
    3. ControlDesigner.Behavior
      I am trying to build a custom designer that is similar to the System.Web.UI.Design.WebControls.TableDesigner. The main feature i need is to be...
    4. ControlDesigner Question
      I'm deriving a Designer from ControlDesigner. The control is working pretty nicely now. What I'd like to add is a verb response that will put...
    5. Problem with ControlDesigner.OnControlResize?
      Hi, Due to the nature of this issue, it will require further research. We will post more info for you as soon as we can. Thank you, Mike...
  3. #2

    Default RE: ControlDesigner.OnPaint

    Hello Breeve,

    As for the Custom ControlDesigner's "OnPaint" issue, I've also noticed
    this when we adding such control in a template container. The design-time
    content of the control in it. The design-time UI methods such as "OnPaint"
    or "GetDesigntimeHtml" will not quite work in "Itemtemplate"(normal display
    template).

    After discussing with some production engineers, we've got the following
    reason on this behavior:


    Controls inside templates (when NOT in template editing mode) render using
    their runtime behavior. For example, a radiobutton with no text renders as
    just a little circle without any additional text. This is because they are
    merely child controls of their container and have no ControlDesigner
    associated with them, so there is no GetDesignTimeHtml being called for
    them (are you seeing otherwise?). By not rendering the [RadioButton1] text
    I'd say you're getting a better WYSIWYG rendering of the control.


    Therefore, when we put the control in GridView or Repeater or FormView's
    ItemTemplate, the control it self is no longer considered in design mode(it
    is just a inner html element of the super control), only the container
    control (GridView or Repeater or FormView) is considered in design-mode and
    will utilize the controldesigner features.


    Hope this helps clarify this.


    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    This posting is provided "AS IS" with no warranties, and confers no rights.

    Steven Cheng[MSFT] Guest

  4. #3

    Default RE: ControlDesigner.OnPaint

    This seems nice in theory, but in reality it doesn't work well. When you say
    the control "renders using their runtime behavior" this is only partially
    true. Yes, while it is true that GetDesignTimeHtml and OnPaint methods are
    only executed in edit template mode, when not in edit mode, however, the
    Control.Context is null while at real runtime it is not null. This makes it
    impossible for us to show a valid image.

    You see, during real runtime we cache the image generated in the ASP.NET
    cache using the Control.Context property. The image URL we send to the client
    points to a custom HttpHandler which ends up resolving the image when the
    browser asks for it. All of this functionality does not work at design time
    at all because the Control.Context is always null. In order to get our image
    to show up in "non edit mode", we would have to create temporary images on
    the users system. This is not good. We were doing that for a breaf time,
    before shipping, but when 2.0 came out the ControlDesigner.OnPaint method was
    godsent. At least partially, because now Microsoft is telling us we don't
    call it in certain scenarios and that is by design.

    Well, the fact remains that the Context is null and Microsoft is not calling
    OnPaint so what are we going to do? It looks buggy to our users to have a
    broken image at design time.
    breeve Guest

  5. #4

    Default RE: ControlDesigner.OnPaint

    Thanks for the reply Breeve,

    Yes, the "renders using their runtime behavior" here just means the control
    in template control's ItemTemplate won't utilize those design-time service
    (getdesigntimhtml or Onpaint ...) to render design-time surface. And I can
    fully understand the pain in your case since you'll need to display an
    image file here.

    Based on my research, it seems this limitation hasn't been added into
    formal plans for next version. However, I would recommend you submit this
    request on our product feedback center so that our product team can hear
    more on this:

    #Visual Studio and .NET Framework Feedback
    [url]http://connect.microsoft.com/feedback/default.aspx?SiteID=210[/url]

    Thanks for your understanding.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.




    Steven Cheng[MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139