473,322 Members | 1,232 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,322 software developers and data experts.

custom container control - wrapping child controls

I am trying to create a custom container control that will only ever contain
a specific type of control.
At design time, when a control of a different type is added to the container
I would like to wrap the control in the proper control type - which is also
a container.

At design time I want to be able to turn this :

<my:container>
<asp:textbox />
</my:container>

into this :

<my:container>
<my:wrapper>
<asp:textbox />
</my:wrapper>
</my:container>

It is no problem to detect what type of object is being added to the control
and I can do the wrapping easy enough for the rendered control , but I can't
see how to change the physical markup as displayed in the designer and
stored in the .aspx file.

Webparts does something similar but it looks like the designer source has
not been made available.

Anyone know how to do this or have any ideas on how this might be done ?

Gerry
Jul 23 '08 #1
5 4057
Hi Gerry,

From your description, you're developing a custom server control which
contains some inner controls, and you want to make some certain kind of
nested subcontrols be wrapper with another control automatically at
design-time, correct?

I've performed some research on this. So far for nested controls, the
custom control itself should be set as "ParseChildren" as false so that
inner markup will be interpreted as control instances. I think you've also
ready done this, correct? Generally, for design-time custoimzation, we
have two tools:

1. A custom control designer

2. A custom control parser

So far I only got some interfaces for customzing the displaying html from
Control Designer , but not the inline markup of the control. Also,
controlbuilder seems focus on the nested control's parsing and population
at runtime. Is there are any particular requirement in your page or
control that it will need such an wrapper element? Maybe we can also look
for some other means on this.

I'll do some further research on this and inform you if I get any new
finding.

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: "gerry" <ge***@newsgroup.nospam>
Subject: custom container control - wrapping child controls
Date: Wed, 23 Jul 2008 09:41:31 -0400
>
I am trying to create a custom container control that will only ever
contain
>a specific type of control.
At design time, when a control of a different type is added to the
container
>I would like to wrap the control in the proper control type - which is
also
>a container.

At design time I want to be able to turn this :

<my:container>
<asp:textbox />
</my:container>

into this :

<my:container>
<my:wrapper>
<asp:textbox />
</my:wrapper>
</my:container>

It is no problem to detect what type of object is being added to the
control
>and I can do the wrapping easy enough for the rendered control , but I
can't
>see how to change the physical markup as displayed in the designer and
stored in the .aspx file.

Webparts does something similar but it looks like the designer source has
not been made available.

Anyone know how to do this or have any ideas on how this might be done ?

Gerry
Jul 24 '08 #2
Hi Gerry,

How are you doing?

Regarding on this issue, I've performed some further research and discussed
with some other ASP.NET engineers.

So far we can think of one way to achieve this, but I think it is total
overkill. Whenever your template is persisted (when GetPersistenceContent()
is called), you could examine your control tree and modify it to make sure
it contains the container controls. You could then persist that control
tree into text, then re-parse it into an ITemplate and set your property to
that value. Then when ASP.NET persists your template it'll persist the
modified template.

Some scenarios that are a bit similar to this are that the MultiView
control can only contain View controls. Similarly, WebPartZones can only
contain WebParts. You might want to dig into their designer and runtime
code to see how they handle this. I've used the reflector tool to inspect
the code abit and find some code logic for gettting the current inner
content of control. But may still need more effort on setting the content.

Have you got any progress on your side?

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: Thu, 24 Jul 2008 07:43:56 GMT
Subject: RE: custom container control - wrapping child controls
>
Hi Gerry,

From your description, you're developing a custom server control which
contains some inner controls, and you want to make some certain kind of
nested subcontrols be wrapper with another control automatically at
design-time, correct?

I've performed some research on this. So far for nested controls, the
custom control itself should be set as "ParseChildren" as false so that
inner markup will be interpreted as control instances. I think you've also
ready done this, correct? Generally, for design-time custoimzation, we
have two tools:

1. A custom control designer

2. A custom control parser

So far I only got some interfaces for customzing the displaying html from
Control Designer , but not the inline markup of the control. Also,
controlbuilder seems focus on the nested control's parsing and population
at runtime. Is there are any particular requirement in your page or
control that it will need such an wrapper element? Maybe we can also look
for some other means on this.

I'll do some further research on this and inform you if I get any new
finding.

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.

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: "gerry" <ge***@newsgroup.nospam>
Subject: custom container control - wrapping child controls
Date: Wed, 23 Jul 2008 09:41:31 -0400
>>
I am trying to create a custom container control that will only ever
contain
>>a specific type of control.
At design time, when a control of a different type is added to the
container
>>I would like to wrap the control in the proper control type - which is
also
>>a container.

At design time I want to be able to turn this :

<my:container>
<asp:textbox />
</my:container>

into this :

<my:container>
<my:wrapper>
<asp:textbox />
</my:wrapper>
</my:container>

It is no problem to detect what type of object is being added to the
control
>>and I can do the wrapping easy enough for the rendered control , but I
can't
>>see how to change the physical markup as displayed in the designer and
stored in the .aspx file.

Webparts does something similar but it looks like the designer source has
not been made available.

Anyone know how to do this or have any ideas on how this might be done ?

Gerry

Aug 4 '08 #3
thanks steven,

I gave up on this for now - I just made it a requirement that the user must
manually wrap the controls - along with a few other manual design time
issues.

I went the same route using reflector trying to trace through how webparts
do it and even how list controls convert an edited list into embedded html
but it didn't help much.

If System.Design.pdb had been included in the framework source distro I
think tracing through the process in the debugger would have helped
immensely - but for whatever reason this was not included. I even tried
recompiling System.Design.dll as exported from reflector - but it appears
that reflector has some issues with its output that would make this a pretty
daunting if not impossible task - the biggest problem being the generated
code calling methods on objects in other assemblies marked as internal. IMO
the framework contains WAY too many internal elements especially trivial
elements - but I digress.

I will dig into this again at a later time - with the extolling of vs
extensibility I would have expected all of the design time capabilitied to
be fully documented and base functionality to be publicly available for use
as base classes rather than undocumented and hidden away in 'internal' code.
Hopefully this stuff is available through vsip or some such and I just
haven't stumbled my way across it yet.

I haven't found any in depth books on the subject of vs design time
support - can you recommend any ?



"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:1U*************@TK2MSFTNGHUB02.phx.gbl...
Hi Gerry,

How are you doing?

Regarding on this issue, I've performed some further research and
discussed
with some other ASP.NET engineers.

So far we can think of one way to achieve this, but I think it is total
overkill. Whenever your template is persisted (when
GetPersistenceContent()
is called), you could examine your control tree and modify it to make sure
it contains the container controls. You could then persist that control
tree into text, then re-parse it into an ITemplate and set your property
to
that value. Then when ASP.NET persists your template it'll persist the
modified template.

Some scenarios that are a bit similar to this are that the MultiView
control can only contain View controls. Similarly, WebPartZones can only
contain WebParts. You might want to dig into their designer and runtime
code to see how they handle this. I've used the reflector tool to inspect
the code abit and find some code logic for gettting the current inner
content of control. But may still need more effort on setting the content.

Have you got any progress on your side?

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: Thu, 24 Jul 2008 07:43:56 GMT
Subject: RE: custom container control - wrapping child controls
>>
Hi Gerry,

From your description, you're developing a custom server control which
contains some inner controls, and you want to make some certain kind of
nested subcontrols be wrapper with another control automatically at
design-time, correct?

I've performed some research on this. So far for nested controls, the
custom control itself should be set as "ParseChildren" as false so that
inner markup will be interpreted as control instances. I think you've also
ready done this, correct? Generally, for design-time custoimzation, we
have two tools:

1. A custom control designer

2. A custom control parser

So far I only got some interfaces for customzing the displaying html from
Control Designer , but not the inline markup of the control. Also,
controlbuilder seems focus on the nested control's parsing and population
at runtime. Is there are any particular requirement in your page or
control that it will need such an wrapper element? Maybe we can also look
for some other means on this.

I'll do some further research on this and inform you if I get any new
finding.

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.

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: "gerry" <ge***@newsgroup.nospam>
Subject: custom container control - wrapping child controls
Date: Wed, 23 Jul 2008 09:41:31 -0400
>>>
I am trying to create a custom container control that will only ever
contain
>>>a specific type of control.
At design time, when a control of a different type is added to the
container
>>>I would like to wrap the control in the proper control type - which is
also
>>>a container.

At design time I want to be able to turn this :

<my:container>
<asp:textbox />
</my:container>

into this :

<my:container>
<my:wrapper>
<asp:textbox />
</my:wrapper>
</my:container>

It is no problem to detect what type of object is being added to the
control
>>>and I can do the wrapping easy enough for the rendered control , but I
can't
>>>see how to change the physical markup as displayed in the designer and
stored in the .aspx file.

Webparts does something similar but it looks like the designer source has
not been made available.

Anyone know how to do this or have any ideas on how this might be done ?

Gerry


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

Yes, for temporary solution, perform runtime checking and control wrapper
will be much easier.

Also, I agree that for ASP.NET custom control programming, the resource for
design-time part is still quite limited and I do have received such
feedback before. So far the MSDN contains some basic design-time
programming reference:

http://msdn.microsoft.com/en-us/libr...ha(VS.85).aspx

For other books, there are some books written by some MVP or other guys:

#Data Source Controls (Part 5 - Design Time Functionality)
http://www.nikhilk.net/DataSourceCon...esignTime.aspx

And I would recommemd you some MS dev engineer's blog since there are some
useful tech articles and information there. Actually, sometimes I also
discuss with some of them for ideas of design-time issues:

http://weblogs.asp.net/leftslipper/a...es-to-consider
-applying-when-writing-a-custom-control.aspx

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: "gerry" <ge***@newsgroup.nospam>
References: <u1**************@TK2MSFTNGP03.phx.gbl>
<01**************@TK2MSFTNGHUB02.phx.gbl>
<1U*************@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: custom container control - wrapping child controls
Date: Tue, 5 Aug 2008 09:01:21 -0400
>thanks steven,

I gave up on this for now - I just made it a requirement that the user
must
>manually wrap the controls - along with a few other manual design time
issues.

I went the same route using reflector trying to trace through how webparts
do it and even how list controls convert an edited list into embedded html
but it didn't help much.

If System.Design.pdb had been included in the framework source distro I
think tracing through the process in the debugger would have helped
immensely - but for whatever reason this was not included. I even tried
recompiling System.Design.dll as exported from reflector - but it appears
that reflector has some issues with its output that would make this a
pretty
>daunting if not impossible task - the biggest problem being the generated
code calling methods on objects in other assemblies marked as internal.
IMO
>the framework contains WAY too many internal elements especially trivial
elements - but I digress.

I will dig into this again at a later time - with the extolling of vs
extensibility I would have expected all of the design time capabilitied to
be fully documented and base functionality to be publicly available for
use
>as base classes rather than undocumented and hidden away in 'internal'
code.
>Hopefully this stuff is available through vsip or some such and I just
haven't stumbled my way across it yet.

I haven't found any in depth books on the subject of vs design time
support - can you recommend any ?
Aug 6 '08 #5
Thanks Steven.

"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:7k**************@TK2MSFTNGHUB02.phx.gbl...
Thanks for your reply Gerry,

Yes, for temporary solution, perform runtime checking and control wrapper
will be much easier.

Also, I agree that for ASP.NET custom control programming, the resource
for
design-time part is still quite limited and I do have received such
feedback before. So far the MSDN contains some basic design-time
programming reference:

http://msdn.microsoft.com/en-us/libr...ha(VS.85).aspx

For other books, there are some books written by some MVP or other guys:

#Data Source Controls (Part 5 - Design Time Functionality)
http://www.nikhilk.net/DataSourceCon...esignTime.aspx

And I would recommemd you some MS dev engineer's blog since there are some
useful tech articles and information there. Actually, sometimes I also
discuss with some of them for ideas of design-time issues:

http://weblogs.asp.net/leftslipper/a...es-to-consider
-applying-when-writing-a-custom-control.aspx

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: "gerry" <ge***@newsgroup.nospam>
References: <u1**************@TK2MSFTNGP03.phx.gbl>
<01**************@TK2MSFTNGHUB02.phx.gbl>
<1U*************@TK2MSFTNGHUB02.phx.gbl>
>>Subject: Re: custom container control - wrapping child controls
Date: Tue, 5 Aug 2008 09:01:21 -0400
>>thanks steven,

I gave up on this for now - I just made it a requirement that the user
must
>>manually wrap the controls - along with a few other manual design time
issues.

I went the same route using reflector trying to trace through how webparts
do it and even how list controls convert an edited list into embedded html
but it didn't help much.

If System.Design.pdb had been included in the framework source distro I
think tracing through the process in the debugger would have helped
immensely - but for whatever reason this was not included. I even tried
recompiling System.Design.dll as exported from reflector - but it appears
that reflector has some issues with its output that would make this a
pretty
>>daunting if not impossible task - the biggest problem being the generated
code calling methods on objects in other assemblies marked as internal.
IMO
>>the framework contains WAY too many internal elements especially trivial
elements - but I digress.

I will dig into this again at a later time - with the extolling of vs
extensibility I would have expected all of the design time capabilitied to
be fully documented and base functionality to be publicly available for
use
>>as base classes rather than undocumented and hidden away in 'internal'
code.
>>Hopefully this stuff is available through vsip or some such and I just
haven't stumbled my way across it yet.

I haven't found any in depth books on the subject of vs design time
support - can you recommend any ?

Aug 6 '08 #6

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

Similar topics

2
by: Juan Romero | last post by:
Hey guys, I am working on a web custom control that basically draws a table (ASP Table) with a few child controls in the cells. I have a command button inside one of these cells. The problem I...
1
by: Chris Newby | last post by:
I have a custom control that derives from the WebControls.Panel class. In a given ASPX document, I have an instance of my custom control with ID set to "MyControl". Then I put a...
9
by: Jaybuffet | last post by:
my aspx has something like this <asp:Repeater id="Repeater1" runat="server"> <ItemTemplate> <mycontrol:ctl id="ctlId" obj='<%# Container.DataItem %>' showItem="true"/> </ItemTemplate>...
0
by: Joe | last post by:
Anyone have any experience using custom snaplines? I have a usercontrol that acts as a container for several child controls. I wrote an inherited ControlDesigner to handle some custom actions...
0
by: pabloazorin | last post by:
I developed a Date Picker web control using C# and .net framework 1.1 I added my control to Visual Studio 2003 IDE toolbar. When I drag and drop my control to design web page, the control renders...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
1
by: mnuckols | last post by:
I am trying to create a custom container control for Windows Forms using C#.NET 2.0. My problem is that I want only part of the control to allow other controls to be placed on it at design time. ...
0
by: gerry | last post by:
I am trying to create a custom container control that will only ever contain a specific type of control. At design time, when a control of a different type is added to the container I would like...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.