asp.net2.0中用户自定义的User Control继承于System.Web.UI.UserControl,而用户自定义的Server Control则继承于System.Web.UI.WebControls.WebControl。要想了解User Control与Server Control的不一样,只须要看看这两个类有什么不一样,以下图。asp.net

- System.Web.UI.UserControl继承于System.Web.UI.TamplateControl;
- System.Web.UI.UserControl实现了System.Web.INamingContainer;
INamingContainer是一个标志性接口它没有定义任何方法。它表示这是一个容器控件,能够加入到页面的控件树中。
- System.Web.UI.UserControl实现了System.Web.IFilterResolutionService;
- System.Web.UI.UserControl实现了System.Web.IUserControlDesignerAccessor。
用于在vs设计视图中访问与设置该控件。
综上所述,User Control与Server Control的最大区别就是:ide
- User Control默认是一个容器控件,而Server Control不是(除非在自定义Server Control时实现INamingContainer);
- User Control能够在vs设计视图中进行可视化设计,而Server Control则只能经过编码进行设计。