473,406 Members | 2,707 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Facade for 3rd party controls, CompositeControl

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
Aug 1 '08 #1
6 1767
It's an odd request, usually you can do this sort of thing quite easily with
a component that doesn't have a user control for instance, a db provider.
With a user interface, things get odd because you have to be concerned with
two paths: backend and front-end.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
-------------------------------------------------------
"Mark" <mm******@nospam.nospamwrote in message
news:4D**********************************@microsof t.com...
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

Aug 3 '08 #2
Hi Alvin...

Thanks for responding.

I bow to your expertise, but if I must press ahead on this route, which do
you think would be the best approach:

1) wrapper the 3rd party components so that they expose a method I *can*
call at most phases (like OnPreRender())

2) Not add my CompositeControl to the page writer.AddControl(), but add the
child component instead

3) Add my CompositeControl and the child control to the page writer but
override my container Render method to do nothing

My container really doesn't want to do anything other than make sure the
3rdparty component of choice gets on the page - don't want any rendering, all
actions would just be a pass-through.

Which of the above would be the best approach, or is there another I've just
missed?
Thanks
Mark
"Alvin Bruney [ASP.NET MVP]" wrote:
It's an odd request, usually you can do this sort of thing quite easily with
a component that doesn't have a user control for instance, a db provider.
With a user interface, things get odd because you have to be concerned with
two paths: backend and front-end.

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
-------------------------------------------------------
"Mark" <mm******@nospam.nospamwrote in message
news:4D**********************************@microsof t.com...
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
Aug 3 '08 #3
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
Aug 4 '08 #4
Hi Steven...

All my attempts have been basically the code you have below. The only
problem is that it doesn't work, which is why I posted here.

Overriding CreateChildControls() gets the ControlCollection populated, but
apparently not rendered.

When I override my CompositeControl.Render or RenderControl methods and
explicitly call Render on the children, I run into the next error -
FreeTextBox2 seems to only initialize certain members during the
OnPreRender() phase, which again doesn't seem to be called when a control is
in a CompositeControl.

So the *next* problem, which cause me to post, is that OnPreRender() is
protected, so I can't override my CompositeControl.OnPreRender() and make it
invoke the OnPreRender() on the children; I can't get to it.

So while it sounds like a nice idea to throw a CompositeControl around it,
it doesn't look like the CompositeControl has the wiring to support passing
through all the actions to the children in the ControlCollection.

That's the nub of my problem.

Thanks
Mark
"Steven Cheng [MSFT]" wrote:
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


Aug 4 '08 #5
Thanks for your reply Mark,

So you used the similar code(for the composite control) but cannot get the
Freetextbox sub control displayed? Regardless of the code and page
template, what I can think about is the control version, what version of
the FreeTextBox control are you using? I'm using the one for .net framework
2.0

http://freetextbox.com/download/default.aspx

And I direclty modify the sample application to use a custom composite
control I used for testing. If you need, I can send you my test page and
control code. You can ping me at the following address:

"stcheng" + @ + "microsoft.com"

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.

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

--------------------
>From: =?Utf-8?B?TWFyaw==?= <mm******@nospam.nospam>
References: <4D**********************************@microsoft.co m>
<U$*************@TK2MSFTNGHUB02.phx.gbl>
>Subject: RE: Facade for 3rd party controls, CompositeControl
Date: Mon, 4 Aug 2008 08:59:00 -0700
>
Hi Steven...

All my attempts have been basically the code you have below. The only
problem is that it doesn't work, which is why I posted here.

Overriding CreateChildControls() gets the ControlCollection populated, but
apparently not rendered.

When I override my CompositeControl.Render or RenderControl methods and
explicitly call Render on the children, I run into the next error -
FreeTextBox2 seems to only initialize certain members during the
OnPreRender() phase, which again doesn't seem to be called when a control
is
>in a CompositeControl.

So the *next* problem, which cause me to post, is that OnPreRender() is
protected, so I can't override my CompositeControl.OnPreRender() and make
it
>invoke the OnPreRender() on the children; I can't get to it.

So while it sounds like a nice idea to throw a CompositeControl around it,
it doesn't look like the CompositeControl has the wiring to support
passing
>through all the actions to the children in the ControlCollection.

That's the nub of my problem.

Thanks
Mark

Aug 5 '08 #6
Hi Mark,

I've just replied your email with a test project(with a custom control
which wrapper FreeTextBox control). Also, i've added some suggestion about
the nested control's auto-generated ID.

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.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Content-Transfer-Encoding: 7bit
From: st*****@online.microsoft.com (Steven Cheng [MSFT])
Organization: Microsoft
Date: Tue, 05 Aug 2008 06:17:08 GMT
Subject: RE: Facade for 3rd party controls, CompositeControl
>Thanks for your reply Mark,

So you used the similar code(for the composite control) but cannot get the
Freetextbox sub control displayed? Regardless of the code and page
template, what I can think about is the control version, what version of
the FreeTextBox control are you using? I'm using the one for .net
framework
>2.0

http://freetextbox.com/download/default.aspx

And I direclty modify the sample application to use a custom composite
control I used for testing. If you need, I can send you my test page and
control code. You can ping me at the following address:

"stcheng" + @ + "microsoft.com"

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...ault.aspx#noti
f
>ications.

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

--------------------
>>From: =?Utf-8?B?TWFyaw==?= <mm******@nospam.nospam>
References: <4D**********************************@microsoft.co m>
<U$*************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: RE: Facade for 3rd party controls, CompositeControl
Date: Mon, 4 Aug 2008 08:59:00 -0700
>>
Aug 7 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: FluffyCat | last post by:
In Febraury - April of 2002 I put together in Java examples of all 23 of the classic "Gang Of Four" design patterns for my website. Partly I wanted to get a better understanding of those patterns....
3
by: Martin | last post by:
Hi, I have created a composite control that has a number of standard asp.net controls on it that can themselves cause postbacks. What i need to do in my composite control is to determine which...
1
by: anonymous.user0 | last post by:
I'm a little confused about the Facade pattern. As I understand it, it's supposed to be a single, simplified interface into a larger amount of subsystems. The question I have is basically how...
1
by: estebistec | last post by:
Hello, I've developed a CompositeControl in C# for ASP.NET 2.0. In this control I am simulating Edit and View modes by hiding or showing appropriate controls (setting Control.Visible). Basically...
5
by: Nathan Sokalski | last post by:
I have a custom control that I wrote (I inherit from System.Web.UI.WebControls.CompositeControl). I dynamically add this control to my Page, but I was told that dynamically added controls do not...
5
by: Nathan Sokalski | last post by:
I am writing a Control that inherits from System.Web.UI.WebControls.CompositeControl. Like many Controls, my Control renders more than just one inner Control. When a postback occurs, I need to get...
3
by: Chad Scharf | last post by:
Ok, as silly as it may sound, I have a situation where I am creating a CompositeControl in ASP.NET 2.0, C#. I have the following code in the CreateChildControls() method that build the control's...
2
by: Nathan Sokalski | last post by:
I am write a CompositeControl, and one of the controls being included is a Repeater. This is my first time including a templated control in a control other than a UserControl. I am not sure how to...
1
by: Andy B | last post by:
How do you keep the user controls in a web application secure? I.e. not allowing access to them from the outside world. I want to have a dll with the user controls and secondary code like custom...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.