GetDesignTimeHTML doesn't fire for PanelDesigner.

Discussion in 'ASP .Net Building Controls' started by Steve Wesorick, Jan 27, 2004.

  1. I have a custom web control that inherits from
    System.Web.UI.WebControls.Panel

    What I want is for developers to be able to drag controls from the
    toolbox, into my control, and have them appear as they would on the
    finished page. My control renders a table around the outside of its
    child controls, and puts a special header row at the beginning of this
    table.

    for example:
    <cc1:myctl id=myctl1 runat=server text="sometext!"
    imageURL="mygif.gif"><span>some content and child
    controls</span></cc1:myctl>

    comes out at run time as:
    <table>
    <tr>
    <td><img src="mygif.gif">sometext!</td>
    </tr>
    <tr>
    <td><span>some content and child controls</span></td>
    </tr>
    </table>

    If I inherit System.Web.UI.Design.ControlDesigner as my designer, I
    can override the GetDesignTimeHTML function, and get everything to
    render correctly at design time. However, you cannot click on the
    child controls, or drag controls from the toolbox onto my custom
    control that way.

    If I inherit System.Web.UI.Design.WebControls.PanelDesigner
    as my designer, then I can drag and drop controls from the toolbox,
    and click on them to edit them, etc. However, I can't figure out how
    to get my custom html to wrap around the design-time control. (At run
    time everything is fine) I've tried overriding the GetDesignTimeHTML
    function, but it doesn't seem to be firing.
    Steve Wesorick, Jan 27, 2004
    #1
    1. Advertising

  2. Hi Steve,

    What you're experiencing its by design. When ReadOnly property is set to
    true (default in ControlDesigner) you can't drag & drop controls and
    GetDesignTimeHTML will be called. Instead, when ReadOnly is set to false
    (which is set in ReadWriteControlDesigner.ctor) GetDesignTimeHTML wont be
    called.

    --
    Victor Garcia Aprea
    Microsoft MVP | ASP.NET
    Looking for insights on ASP.NET? Read my blog:
    http://obies.com/vga/blog.aspx

    To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
    "Steve Wesorick" <> wrote in message
    news:...
    > I have a custom web control that inherits from
    > System.Web.UI.WebControls.Panel
    >
    > What I want is for developers to be able to drag controls from the
    > toolbox, into my control, and have them appear as they would on the
    > finished page. My control renders a table around the outside of its
    > child controls, and puts a special header row at the beginning of this
    > table.
    >
    > for example:
    > <cc1:myctl id=myctl1 runat=server text="sometext!"
    > imageURL="mygif.gif"><span>some content and child
    > controls</span></cc1:myctl>
    >
    > comes out at run time as:
    > <table>
    > <tr>
    > <td><img src="mygif.gif">sometext!</td>
    > </tr>
    > <tr>
    > <td><span>some content and child controls</span></td>
    > </tr>
    > </table>
    >
    > If I inherit System.Web.UI.Design.ControlDesigner as my designer, I
    > can override the GetDesignTimeHTML function, and get everything to
    > render correctly at design time. However, you cannot click on the
    > child controls, or drag controls from the toolbox onto my custom
    > control that way.
    >
    > If I inherit System.Web.UI.Design.WebControls.PanelDesigner
    > as my designer, then I can drag and drop controls from the toolbox,
    > and click on them to edit them, etc. However, I can't figure out how
    > to get my custom html to wrap around the design-time control. (At run
    > time everything is fine) I've tried overriding the GetDesignTimeHTML
    > function, but it doesn't seem to be firing.
    Victor Garcia Aprea [MVP], Jan 28, 2004
    #2
    1. Advertising

  3. Thanks, Victor. That is helpful to know. It gives me some ideas
    about alternative ways to proceed with this.

    The thing that got me wondering about is that something is rendering a
    DIV tag (Or something similar) around my read-write control at design
    time. I can tell, because if I set the Backcolor of my control (Since
    it inherits from Panel) the backcolor of the control changes, and all
    of the child controls have a color behind them at design time. What I
    would like to do is override this so that instead of writing a
    <DIV>...ChildControls...</DIV> it writes something more like
    <table><TR><TD>MyCustomStuff</td></tr><tr><td><DIV>...ChildControls...</DIV></td></tr></table>
    at design time. Is there another rendering function I can override to
    accomplish this?

    An alternative might be to give the developer the option to switch
    between ReadOnly and Read-Write modes at design time. Maybe by double
    clicking on the control, or via a context menu (Similar to the way you
    edit a Template Column in a Data Grid Control).

    Does anyone know how to add a context menu to a control designer? Or
    how you go about capturing the double click event? Both of these
    would also be helpful in future component designs.


    Thanks again!
    -Steve

    "Victor Garcia Aprea [MVP]" <> wrote in message news:<>...
    > Hi Steve,
    >
    > What you're experiencing its by design. When ReadOnly property is set to
    > true (default in ControlDesigner) you can't drag & drop controls and
    > GetDesignTimeHTML will be called. Instead, when ReadOnly is set to false
    > (which is set in ReadWriteControlDesigner.ctor) GetDesignTimeHTML wont be
    > called.
    >
    > --
    > Victor Garcia Aprea
    > Microsoft MVP | ASP.NET
    > Looking for insights on ASP.NET? Read my blog:
    > http://obies.com/vga/blog.aspx
    Steve Wesorick, Jan 28, 2004
    #3
  4. OK, so I figured out how to add a context menu to my control designer:

    Public Sub New()
    MyBase.new()
    Me.Verbs.Add(New
    System.ComponentModel.Design.DesignerVerb("Change Read Only", AddressOf
    EditFilterOptions))
    End Sub

    Public Sub EditFilterOptions(ByVal sender As Object, ByVal e As
    EventArgs)
    Me.ReadOnly = not Me.ReadOnly
    End Sub


    Now the problem is that changing the value of the "ReadOnly" property
    doesn't seem to do anything, unless it happens in the Sub New(). How do
    I notify my control designer that the ReadOnly Propery has changed, so
    that I can switch my control from drag and drop mode, to full display
    mode?

    I've tried setting me.IsDirty to true, and calling me.Initialize, and
    me.InitializeNonDefault, but none of them seem to do the trick.

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Steve Wesorick, Jan 28, 2004
    #4
    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. Daniel Maycock via .NET 247

    My Threading Timer Doesn't Fire

    Daniel Maycock via .NET 247, Mar 28, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    529
    steve
    Mar 30, 2005
  2. Joshua Flanagan

    Force new call to GetDesignTimeHtml

    Joshua Flanagan, Jan 4, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    577
    Joshua Flanagan
    Jan 4, 2006
  3. Replies:
    16
    Views:
    616
    Jarek Zgoda
    Aug 1, 2005
  4. Luciano Bargmann

    GetDesignTimeHtml() is never called in ReadWriteControlDesigner

    Luciano Bargmann, Sep 14, 2005, in forum: ASP .Net Building Controls
    Replies:
    2
    Views:
    133
    n1patrick
    Sep 16, 2005
  5. Nicolas LeBlanc

    Problem with ControlDesigner and GetDesignTimeHtml

    Nicolas LeBlanc, Jul 29, 2004, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    137
Loading...

Share This Page