Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Facade for 3rd party controls, CompositeControl

Reply
Thread Tools

Facade for 3rd party controls, CompositeControl

 
 
Mark
Guest
Posts: n/a
 
      08-01-2008
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


 
Reply With Quote
 
 
 
 
Alvin Bruney [ASP.NET MVP]
Guest
Posts: n/a
 
      08-03-2008
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>

 
Reply With Quote
 
 
 
 
Mark
Guest
Posts: n/a
 
      08-03-2008
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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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
> >
> >

 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      08-04-2008
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:
http://www.velocityreviews.com/forums/(E-Mail Removed).

==================================================
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==?= <(E-Mail Removed)>
>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
>
>
>


 
Reply With Quote
 
Mark
Guest
Posts: n/a
 
      08-04-2008
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:
> (E-Mail Removed).
>
> ==================================================
> 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==?= <(E-Mail Removed)>
> >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
> >
> >
> >

>
>

 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      08-05-2008
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:
(E-Mail Removed).

==================================================
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==?= <(E-Mail Removed)>
>References: <(E-Mail Removed)>

<U$(E-Mail Removed)>
>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
>
>


 
Reply With Quote
 
Steven Cheng [MSFT]
Guest
Posts: n/a
 
      08-07-2008
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:
(E-Mail Removed).

==================================================
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: (E-Mail Removed) (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:
>(E-Mail Removed).
>
>================================================= =
>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==?= <(E-Mail Removed)>
>>References: <(E-Mail Removed)>

><U$(E-Mail Removed)>
>>Subject: RE: Facade for 3rd party controls, CompositeControl
>>Date: Mon, 4 Aug 2008 08:59:00 -0700

>
>>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Wonder why old 4/3rd lenses are slow on m4/3rd bodies? RichA Digital Photography 8 03-02-2012 11:40 PM
Facade for 3rd party controls, CompositeControl? Mark ASP .Net Building Controls 1 08-04-2008 03:25 AM
3rd Party app stopping Zero config service on startup =?Utf-8?B?QW5ndXMgUm9va2U=?= Wireless Networking 1 08-20-2005 06:55 AM
Spybot's advice for blocking 3rd party cookies with Firefox History Fan Firefox 2 08-11-2005 06:23 AM
Re: Request: A+ Complete 3rd edition (PDF) [1/1] - A+ Complete 3rd edition.txt (1/1) Spammy Sammy A+ Certification 0 03-04-2005 12:55 PM



Advertisments