Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Element 'CompositeBoundField' is not a known element. (trying to extend BoundField server control)

VS2010, .Net 4.0

In trying to extend the asp.net BoundField server control, as described here:
http://iridescence.no/post/FixingBoundFieldSupportforCompositeObjects.aspx

I have created a class:

using System.Web.UI;
using System.Web.UI.WebControls;

namespace CustomControls
{ 
    public class CompositeBoundField : BoundField
    {
        protected override object GetValue(Control controlContainer)
        {
            object item = DataBinder.GetDataItem(controlContainer);
            return DataBinder.Eval(item, this.DataField);
        }
    }
}

I've registered it from my page:

<%@ Register TagPrefix="cc" Namespace="CustomControls" %>

...and on that page, I am attempting to use it like so:

<asp:GridView ID="gridDataSource" runat="server">
    <Columns>
        <cc:CompositeBoundField DataField="Application.ApplicationName" HeaderText="ApplicationName" />
    </Columns>
    </asp:GridView>

However, I am getting a compiler warning:

Element 'CompositeBoundField' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing.    

And when I run, I get the error:

Parser Error 
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Unknown server tag 'cc:CompositeBoundField'.

Any ideas what I'm doing wrong?

I tried this:
http://blog.tentaclesoftware.com/archive/2010/07/21/95.aspx

like image 466
tbone Avatar asked Dec 11 '25 18:12

tbone


1 Answers

In the Register declaration, the Assembly is mandatory:

<%@ Register Namespace="CustomControls" TagPrefix="cc" Assembly="MyCompany.MyApp.WebApp" %>
like image 117
tbone Avatar answered Dec 14 '25 20:12

tbone