Force new call to GetDesignTimeHtml

  • Thread starter Joshua Flanagan
  • Start date
J

Joshua Flanagan

I have a custom CompositeControl (FooControl) whose child controls are
determined at runtime. I created a custom CompositeControlDesigner
(FooControlDesigner) which displays the control at design time. In
GetDesignTimeHtml, I call a method on FooControl to create some "dummy"
child controls to simulate the child controls that would be created at
runtime, and then call its RenderControl() method, passing an HtmlWriter
wrapped around a StringWriter. I then use the contents of the
StringWriter as the return value of GetDesignTimeHtml.

This works perfectly as-is - my design time view looks just like the
runtime view (except it has dummy controls standing in for the controls
discovered at runtime).

Now I would like to give the user the ability to see an alternate view
at design time. By alternate view, I just mean it will use a different
set of dummy child controls. I've decided to implement this as a Smart
Tag on the designer. I've overridden the ActionLists property on
FooControlDesigner so that it adds DesignerActionPropertyItem menu item
that wraps a boolean property. The Smart Tag correctly renders as a
checkbox. When the user checks the checkbox, it should change the design
time view to use the "alternate" set of dummy controls. When they clear
the checkbox, it should change the design time view to use the default
set of dummy controls.

However, when I check or clear the checkbox on the designer, it has no
effect on the design view of my control. I've seen other posts that
mention clearing the Controls property of FooControl, or settings
ChildControlsCreated = false, but neither of those seem to have an
effect. None of them seem to trigger a new call to GetDesignTimeHtml
while the user is still in design view.

This is what I want to happen:

1) Check box on Smart Tag changed -> 2) calls property setter on
DesignerActionList derived class -> 3) calls property setter on
FooControlDesigner -> 4) changes internal state of designer and 5)
forces the designer surface (VS.NET) to call GetDesignTimeHtml again on
my designer so I can return the new HTML -> 6) users sees new view of
control on designer surface.

Steps 1-4 are working. What do I need to do to get steps 5 & 6 to work?


[Originally posted on at http://forums.asp.net/1157233/ShowPost.aspx but
I'm not sure how much attention that will get]
 

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

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top