VS2010,.Net 4.0
尝试扩展asp.net BoundField服务器控件时,如下所述:
http://iridescence.no/post/FixingBoundFieldSupportforCompositeObjects.aspx
我创建了一个类:
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);
}
}
}
我已经从我的页面注册了它:
<%@ Register TagPrefix="cc" Namespace="CustomControls" %>
...在该页面上,我试图像这样使用它:
<asp:GridView ID="gridDataSource" runat="server">
<Columns>
<cc:CompositeBoundField DataField="Application.ApplicationName" HeaderText="ApplicationName" />
</Columns>
</asp:GridView>
但是,我收到编译器警告:
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.
当我跑步时,我收到错误:
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'.
任何想法我做错了什么?
我试过这个:
http://blog.tentaclesoftware.com/archive/2010/07/21/95.aspx
答案 0 :(得分:4)
在注册声明中,大会是强制性的:
<%@ Register Namespace="CustomControls" TagPrefix="cc" Assembly="MyCompany.MyApp.WebApp" %>
答案 1 :(得分:0)
检查Assembly属性是否包含完整的强名称,例如 Assembly =&#34; MyCompany.MyApp.WebApp,Version = 3.42.0.0,Culture = neutral,PublicKeyToken = 674cf0e5bf72fa08&#34;