What is wrong with my CompositeDataBoundControl?
I have a CompositeDataBoundControl defined as below:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ReportSection.ascx.cs" Inherits="WebReports.ReportSection" %>
<div class="report-section span-24">
<h3>
<%= Title %></h3>
</div>
public partial class ReportSection : Compos开发者_开发技巧iteDataBoundControl
{
public string Title { get; set; }
protected override int CreateChildControls(IEnumerable dataSource, bool dataBinding)
{
//throw new NotImplementedException();
return 1; // JUst something to avoid exceptions.
}
}
Yet when I try and load a web form containing this control, I get the following parser error:
'WebReports.ReportSection' is not allowed here because it does not extend class 'System.Web.UI.UserControl'.
This seems very odd to me, because I get the impression that CompositeDataBoundControl is intended as a base class for user controls, or is it perhaps only for use with server controls?
It is intended for server controls, not UserControls. UserControls are more similar to Pages than to other controls (both inherit from TemplatedControl).
You can see from the MSDN description for CompositeDataBoundControl that it's not really intended for user controls:
Represents the base class for a tabular data-bound control that is composed of other server controls.
精彩评论