[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.buildingcontrols

Masquerading as a Different Control at Design Time

Mark Olbert

2/16/2007 4:36:00 PM

I'm building a custom control which is essentially a customized version of the Wizard control, although it doesn't derive from the
Wizard class. It's designed so that you can add a sequence of a limited number of types of steps to the control (e.g., an
Introduction step, a grid-select step).

The custom control is derived from CompositeDataBoundControl, but its sole child control is an instance of Wizard.

I'd like to be able to use the WizardDesigner to provide design-time support. However, because the class is derived from
CompositeDataBoundControl rather than Wizard, that won't work.

1) Is there a way to tell the designer to work with the single child control, rather than the custom control itself?

2) If #1 is impossible or too difficult, is there a way of adding the databound control logic to a class derived from Wizard, rather
than CompositeDataBoundControl? Wizard itself does not have the internal databound control plumbing (e.g., DataSource property). But
are there a set of interfaces that could be implemented to add databinding support to a derived Wizard class?

- Mark
3 Answers

wawang

2/20/2007 10:03:00 AM

0

Hi Mark,

For 1), I don't think it's possible to make the designer of Wizard work
when the Wizard is a constituent control of your custom control, since the
designer of Wizard is not actually created at all at design-time.

For 2), unfortunately a data bound control doesn't have some necessary
interfaces, it's actually inherited from BaseDataBoundControl.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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


Mark Olbert

2/20/2007 2:50:00 PM

0

Walter,

Thanks for the info. I want to make sure I understand what you said about the first question I raised. If I'm getting you, you're
saying that control designers are only called for the "top level" control at design time. In other words, if I create a composite
control (MyTopMostControl) which contains another composite custom control (MyControl), and if I have designers for both
(MyTopMostControlDesigner and MyControlDesigner), only MyTopMostControlDesigner will get called.

Is my understanding correct? The reason I'm focusing on this is because (as you may have seen in some other posts on this newsgroup)
I am having a devil of a time getting a composite control containing a GridView to display dummy data in the GridView at designtime.
I've determined that the way dummy data gets inserted into a GridView at designtime is driven solely by the GridViewDesigner, so
what you're telling me here is that getting a child GridView control to show dummy data at design time may be impossible. If I could
confirm that I'll stop wasting my time trying to make it happen.

- Mark

wawang

2/21/2007 3:30:00 AM

0

Hi Mark,

Yes only the MyTopMostControlDesigner will get called.

To verify this, use following steps:

1) Create a new class library, edit Class1.cs as:

namespace ClassLibrary1
{
[Designer(typeof(Class1Designer))]
public class Class1 : WebControl
{
}

public class Class1Designer : ControlDesigner
{
public Class1Designer()
{
Debugger.Break();
}

public override string GetDesignTimeHtml()
{
return "Class1";
}
}

public class Class2 : CompositeControl
{
private Class1 _c1;

protected override void CreateChildControls()
{
Controls.Clear();

_c1 = new Class1();
Controls.Add(_c1);
}
}
}


2) Configure this class library to launch Visual Studio 2005 (devenv.exe)
when debugged.

3) Start debugging, in the new instance of VS2005, create a new website

4) Add ClassLibrary1.dll from step 1) to the toolbox. It will add Class1
and Class2 to the toolbox.

5) Now drag an instance of Class1 to the designer surface of a webform,
note the first instance of VS2005 IDE will break in Class1Designer's
constructor.

6) Now delete the Class1 instance and drag an instance of Class2 to the
webform, the debugger will not break this time.

Regarding your "GridView as child control" issue, yes I've discussed with
Steven. He's still performing some research to see if there's any
workaround.


Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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