Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / December 2007

Tip: Looking for answers? Try searching our database.

Control, Web Control and Composite Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
shapper - 19 Dec 2007 21:25 GMT
Hello,

I am working in a class library with various custom controls.

In which cases should a control inherit Control, WebControl and
CompositeControl classes?

And when should a custom control implement INamingContainer?

In this moment I am working on a custom control that is composed by a
TextBox, a Label, two Validator controls and a button.

I don't want it to render a tag around these controls. Should I, in
this case, inherit it from Composite Control? And do I need to
implement INamingContainer?

Thanks,

Miguel
Kevin Spencer - 20 Dec 2007 12:39 GMT
System.Web.UI.Control is the base class for all ASP.Net Controls.
System.Web.UI.WebControls.WebControl inherits Control, and is the base class
for all ASP.Net WebControls. It contains a number of common properties and
methods that are used by all WebControls. You would inherit this class when
you want to employ some or all of those additional properties and methods.

System.Web.UI.WebControls.CompositeControl is the base class for all
WebControls that host other System.Web.UI.Controls. It is used when you want
to composite a number of Controls into a single Control. It is a container
which serves as the intermediary and coordinator of the Controls it
contains. It implements INamingContainer, which is an interface that ensures
that each Control has a unique ClientID, by combining their ID properties
with the INamingContainer Control in which they are hosted.

You probably want to create a CompositeControl. The following MSDN pages
should help with this:

http://msdn2.microsoft.com/en-us/library/zt27tfhy.aspx
http://msdn2.microsoft.com/en-us/library/3257x3ea.aspx

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

> Hello,
>
[quoted text clipped - 15 lines]
>
> Miguel
shapper - 20 Dec 2007 14:50 GMT
> System.Web.UI.Control is the base class for all ASP.Net Controls.
> System.Web.UI.WebControls.WebControl inherits Control, and is the base class
[quoted text clipped - 41 lines]
>
> > Miguel

I am having a problem here with Composite Control. It "wrappes" the
controls in a Span Tag.
Sure I can override the BeginTag but what I would like would to not
render any tag at all.
Just renders the controls inside the custom control.

I was able to pull this by inheriting it from Control.
So I have a Custom control, inheriting Control and Implementing
INamingContainer, which contains various controls.
This way it renders all child controls but without any wrapper tag.
Is this ok?

Thanks,
Miguel
bruce barker - 20 Dec 2007 16:51 GMT
sure, or if you want the composite control, just override  RenderBeginTag and
RenderEndTag and make them nop's.

the main disadvantage of not using a span or div, is that the controls do
not have a common parent in the dom, so absolute postioning will not work
without client code to apply it to each element.

-- bruce (sqlwork.com)

> > System.Web.UI.Control is the base class for all ASP.Net Controls.
> > System.Web.UI.WebControls.WebControl inherits Control, and is the base class
[quoted text clipped - 56 lines]
> Thanks,
> Miguel
Peter Bucher [MVP] - 21 Dec 2007 09:32 GMT
Hello

> sure, or if you want the composite control, just override  RenderBeginTag
> and
> RenderEndTag and make them nop's.
Or simply overwrite the property "TagKey" and return the desired value.

Signature

Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.aspnetzone.de/ - ASP.NET Zone, die ASP.NET Community
http://www.aspnetzone.de/blogs/peterbucher/ - Auf den Spuren von .NET

shapper - 26 Dec 2007 14:49 GMT
> sure, or if you want the composite control, just override  RenderBeginTag and
> RenderEndTag and make them nop's.
[quoted text clipped - 69 lines]
> > Thanks,
> > Miguel

"sure, or if you want the composite control, just override
RenderBeginTag and
RenderEndTag and make them nop's. "

What do you mean with nop's? Can you give me a sample code?

Thanks,
Miguel
Kevin Spencer - 21 Dec 2007 11:44 GMT
That sounds like an excellent solution.

Signature

HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

>> System.Web.UI.Control is the base class for all ASP.Net Controls.
>> System.Web.UI.WebControls.WebControl inherits Control, and is the base
[quoted text clipped - 63 lines]
> Thanks,
> Miguel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.