views:

59

answers:

2
  1. I want to create control which would contain other controls.

  2. For these other controls I want to create "base" control with some default look and background logic and then derive all other controls from this "base" control.

Is this possible, and how it can be done ?

EDIT: With nesting I mean something like master pages. I would like to have "master control" and within this master control I would like place another controls.

A: 
  1. Yes, controls can have other controls; for custom classes, you can inherit from CompositeControl for this purpose.
  2. I'm not quite sure what you are asking for... you can programmably change these controls to affect their style/logic, but that can be a lot of work to account for that variability. What exactly do you want to change?
Brian
+2  A: 
  1. It is possible. You have to register your control on the one that contains it.

    <%@ Register TagName="Control" TagPrefix="Tag" Src="source/to/your.ascx" %>

    and then use it like:

    <Tag:Control ID="control" runat="server" />

  2. You can inherit code (ascx.cs). All you have to do is to create a base class that inherits from System.Web.UI.UserControl and then inherit from your base class in your control. I don't know about any way of inheriting look (ascx file).

Simon
With nesting I mean something like master pages. I would like to have "master control" and within this master control I would like place another controls.
Primoz