0

我使用 Umbraco 用户控件包装器在 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)

我不知道出了什么问题?

4

1 回答 1

2

这是一个无效的强制转换,它试图将您的自定义shopdata用户控件强制转换IUsercontrolDataEditor为无效的。

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

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

于 2013-02-20T11:59:27.807 回答