Hi Mark,
As for composite control, I think using "CreateChildControls" method is the
reasonable approach. For your scenario, if you want to wrapper some other
existing 3rd party control in your composite control. You can simply
override the composite control and add the 3rd party control instance into
its "Controls" colleciton, and the runtime will automatically render the
nested controls. For example:
=============================
[DefaultProperty("Text")]
[ToolboxData("<{0}:ServerControl1 runat=server></{0}:ServerControl1>")]
public class ServerControl1 : CompositeControl
{
.......................
protected override void CreateChildControls()
{
Controls.Clear();
Button btn = new Button();
btn.ID = "btnOne";
btn.Text = "Button One";
btn.Click += delegate { Page.Response.Write("<br/>button one is
clicked!"); };
Controls.Add(btn);
Controls.Add(new LiteralControl("<br/><br/>"));
//add FreeTextBox
FreeTextBox ftb = new FreeTextBox();
ftb.ID = "ftb1";
Controls.Add(ftb);
}
}
=========================================
the above composite control will output a Button and a FreeTextBox control
as child control on page.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>From: =?Utf-8?B?TWFyaw==?= <mm******@nospam.nospam>
Subject: Facade for 3rd party controls, CompositeControl
Date: Fri, 1 Aug 2008 15:03:09 -0700
>
Hi...
Tried posting this on Build Controls but then saw that's a pretty slow
group...
Kind of a typical request from product management - they want to be able
to
>swap in different 3rd party controls depending on their whim and the day.
In
>this case, they want to support FreeTextBox and Cute Editor interchangably.
I've been trying to put together a container control derived from
CompositeControl to put a facade around the interaction. Depending on the
configuration, I want to put a FreeTextBox2 or a cute editor control into
the
>ControlCollection.
I overrode CreateChildControls() to set things up. That seems to get the
controls created and initialized, but not rendered.
I overrode my CompositeControl.Render() method to render the child, but
FreeTextBox2 (my first test case) has some member variables that are only
initialized in FreeTextBox2.OnPreRender(), which apparently hasn't been
called.
I tried to override my CompositeControl.OnPreRender() but since
OnPreRender() is protected, I can't call my child
FreeTextBox2.OnPreRender().
>
Am I just barking up the wrong tree here? What is the best way to make a
shell container just to hold another container of choice? How do you get
the
>controls in the collection hooked up to get all of the various calls in
the
>stages of execution?
Thanks
Mark