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

Custom control that can contain other controls

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:
<my:RoundedCornerBox id=foo runat=server>
Content1
Content2
</my:RoundedCornerBox>

renders as:

<div class=foobar>
Content.
Content.
</div>

I don't think this is possible with Web User Controls.

Thanks,

Nick...
PS the above example is vastly simplified but demonstrates the concept
what I need to do.
Jan 8 '07 #1
11 3249
"Nick Gilbert" <ni***@newsgroup.nospamwrote in message
news:On**************@TK2MSFTNGP04.phx.gbl...
I don't think this is possible with Web User Controls.
If you mean something like this: http://www.markrae.com/contact/quote.aspx

then it most certainly is possible... :-)

Is that what you mean...?
Jan 8 '07 #2
If you mean something like this: http://www.markrae.com/contact/quote.aspx
>
then it most certainly is possible... :-)

Is that what you mean...?
Yes that's almost exactly what I need - just in green :)

How did you do that?

Nick...
Jan 8 '07 #3
If you mean something like this: http://www.markrae.com/contact/quote.aspx
>
then it most certainly is possible... :-)

Is that what you mean...?
Yes that's almost exactly what I need - just in green :)

How did you do that?

Nick...
Jan 8 '07 #4
"Nick Gilbert" <ni***@newsgroup.nospamwrote in message
news:45**************@newsgroup.nospam...
>If you mean something like this:
http://www.markrae.com/contact/quote.aspx

then it most certainly is possible... :-)

Is that what you mean...?

Yes that's almost exactly what I need - just in green :)

How did you do that?
It's a usercontrol originally developed by Scott Mitchell which I modified
to produce XHTML-compliant markup.

You can download it from the 4GuysFromRolla site:
http://aspnet.4guysfromrolla.com/articles/081104-1.aspx
Jan 8 '07 #5
It's a usercontrol originally developed by Scott Mitchell which I modified
to produce XHTML-compliant markup.
Thanks for the link.

I'm actually quoted on that page "Special thanks to Nick Gilbert for
helping..."

You would think I would remember wouldn't you?! I must have had too
much alcohol over Christmas! :)

Thanks,

Nick...
Jan 8 '07 #6
"Nick Gilbert" <ni***@newsgroup.nospamwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
>It's a usercontrol originally developed by Scott Mitchell which I
modified to produce XHTML-compliant markup.

Thanks for the link.

I'm actually quoted on that page "Special thanks to Nick Gilbert for
helping..."

You would think I would remember wouldn't you?! I must have had too much
alcohol over Christmas! :)
ROTFLMAO!!!
Jan 8 '07 #7
I've just remembered why I don't use that code. You can't specify the
corner images and so are restricted to very basic designs. Also it
renders using tables - which makes for very heavy HTML if you have lots
of boxes on one page. But hopefully I can use the code to find out how
to write my "wrapper" control that will mark things up as a box with
rounded corners.

Currently, my code to make a rounded corner box doesn't use any tables
and the amount of HTML per box is very small.

Nick...
Jan 8 '07 #8
"Nick Gilbert" <ni***@newsgroup.nospamwrote in message
news:e9**************@TK2MSFTNGP02.phx.gbl...
You can't specify the corner images and so are restricted to very basic
designs.
You don't need to specify the images - it creates them dynamically (if they
don't already exist) according to the settings you choose - it's totally
flexible in that way...
Also it renders using tables - which makes for very heavy HTML if you have
lots of boxes on one page.
I have to say that I don't find it heavy at all...
Currently, my code to make a rounded corner box doesn't use any tables and
the amount of HTML per box is very small.
Well, I'd certainly be interested to see that...

I believe rounded corners is something being considered for the next
standardisation of CSS...
Jan 8 '07 #9
Hello Nick,

I'm not quite sure about what your wrap control will look like(for UI
appearance), however, for building such a custom control through available
ASP.NET control development features, here are some suggestions:

1. I think ascx usercontrol is not suitable here, and a custom web server
control is preferred.

2. As what you need is the following like control, the control itself can
contain discretionary child content(normal html or other server controls):

=========
<my:RoundedCornerBox id=foo runat=server>
Content1
Content2
</my:RoundedCornerBox>
===========

and after rendering, all the child content will be also wrapped in
container html set such as

===========
<div>
child content rendering...
</div>
===========

Thus, I think a good choice is to use ASP.NET custom template control(just
like the LoginView control...) which can let you define a custom inner
template, and those child content in the template will always be rendered
within the container(you determined in your toplevel control's control
creation code logic).

Here are some MSDN reference and web article introduce developing custom
template control.

#Building Templated Custom ASP.NET Server Controls
http://msdn2.microsoft.com/en-us/library/aa478964.aspx

#Creating a Templated Control
http://www.samspublishing.com/articl...&seqNum=7&rl=1

For your scenario, you can define a Template property for your custom wrap
control(which use to contain any content you want to include), then in your
control's main control creation codelogic, you first create the outside
wrapper html content(<div>, <tableor ...) and add the template instanced
sub controls into the outside wrapper. Also, you can use multi-templates if
necessary, it's quite flexible.

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead

==================================================

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.


Jan 9 '07 #10
Hi,

I have managed to do what I want by making my own control like this:

[DefaultProperty("Text"), PersistChildren(true), ParseChildren(false)]
public class RoundedCornerBox : System.Web.UI.WebControls.WebControl {
public override void RenderBeginTag(HtmlTextWriter writer) {
writer.Write("(START HTML)");
}

public override void RenderEndTag(HtmlTextWriter writer) {
writer.Write("(END HTML)");
}
}
I'm not sure if this is the best way of doing it, but it seems to work OK.

Nick...

Jan 10 '07 #11
Thanks for your followup Nick,

Glad that you've found a solution. BTW, if you have interests try the
template control approach and if there is anything else we can help, please
feel free to post here.

Have a good day!

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
This posting is provided "AS IS" with no warranties, and confers no rights.
Jan 11 '07 #12

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

Similar topics

2
by: Jay Walker | last post by:
I created a custom DataGridColumn based on Marcie Robillard's MSDN Article: Creating Custom Columns for the ASP.NET Datagrid...
1
by: Earl Teigrob | last post by:
Background: When I create a ASP.NET control (User or custom), it often requires security to be set for certain functionality with the control. For example, a news release user control that is...
21
by: One Handed Man \( OHM - Terry Burns \) | last post by:
When using a custom control. In order to check and see if values have changed one has to implement the IPostBackDataCollection interface. The values returned for the control seem to be simply a...
1
by: Lamont Adams | last post by:
Hi all, I've created numerous custom controls of varying complexity, but I've been on this problem for a day and a half, and I can't figure this mystery out. I hope one of you kind folks can...
0
by: Jeremy Chapman | last post by:
I have included below virtually all the code to a control I'm trying to build. My issue is that an array list property in my control does not get persisted properly to the aspx page code in design...
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...
1
by: rizwanahmed24 | last post by:
Hello i have created a custom control. i have placed two template controls on it. One is check box and second is picture box. The custom control also contain two picture boxes as property. These...
5
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...
4
by: Jeff | last post by:
hi asp.net 2.0 I have created a custom web control, here is it's header: <%@ Control Language="C#" AutoEventWireup="true" CodeFile="EditUserBox.ascx.cs" Inherits="Controls_EditUserBox" %> ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.