Umbraco usercontrol包装器出错

时间:2013-02-20 11:10:30

标签: asp.net umbraco

我使用Umbraco usercontrol包装器在umbraco中创建了一个自定义数据类型但是当我在umbraco节点中运行它时会给我一个错误

 At /umbraco/editContent.aspx?id=2969 (Referred by: http://aksp:201/umbraco/umbraco.aspx): System.InvalidCastException: Unable to cast object of type 'ASP.usercontrols_shopdata_ascx' to type 'umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor'.     at umbraco.editorControls.userControlGrapper.usercontrolDataEditor.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.AddedControl(Control control, Int32 index)     at umbraco.controls.ContentControl.addControlNew(Property p, TabPage tp, String Caption)     at umbraco.controls.ContentControl.CreateChildControls()     at System.Web.UI.Control.EnsureChildControls()     at umbraco.controls.ContentControl.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Control.AddedControl(Control control, Int32 index)     at umbraco.cms.presentation.editContent.OnInit(EventArgs e)     at System.Web.UI.Control.InitRecursive(Control namingContainer)     at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

我不知道出了什么问题?

1 个答案:

答案 0 :(得分:2)

这是一个无效的投放,它正在尝试将您的自定义shopdata用户控件投射到无效的IUsercontrolDataEditor

确保您的控件实现umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor接口

Here here是如何使用UmbracoUsercontrol包装器创建自定义数据类型的很好指南。