开发者

Can you nest asp.net controls?

  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开发者_C百科 like to have "master control" and within this master control I would like place another controls.


  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).


  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?
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜