Control, Web Control and Composite Control

Control, Web Control and Composite Control

Post by shappe » Fri, 21 Dec 2007 06:25:54


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
 
 
 

Control, Web Control and Composite Control

Post by Kevin Spen » Fri, 21 Dec 2007 21:39:11

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://www.yqcomputer.com/
http://www.yqcomputer.com/

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP

 
 
 

Control, Web Control and Composite Control

Post by shappe » Fri, 21 Dec 2007 23:50:39

On Dec 20, 12:39 pm, "Kevin Spencer" < XXXX@XXXXX.COM >




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
 
 
 

Control, Web Control and Composite Control

Post by Peter Buch » Sat, 22 Dec 2007 18:32:41

Hello

Or simply overwrite the property "TagKey" and return the desired value.

--
Gruss, Peter Bucher
Microsoft MVP - Visual Developer ASP / ASP.NET, Switzerland
http://www.yqcomputer.com/ , die ASP.NET Community
http://www.yqcomputer.com/
 
 
 

Control, Web Control and Composite Control

Post by shappe » Thu, 27 Dec 2007 23:49:27

n Dec 20, 4:51 pm, bruce barker
< XXXX@XXXXX.COM > wrote:

"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