Sitecore 8.2 WFFM自定义字段:[WFFM]无法创建类型的实例

时间:2018-07-12 14:36:45

标签: list dropdown custom-fields web-forms-for-marketers sitecore8.2

我正在创建自定义下拉列表字段,因为我需要为我的下拉列表设置初始值。我已经在Sitecore和相应的类和html中创建了一个字段项,但是当我使用表单加载页面时,下拉列表失败,并且我的日志中有以下消息:

[WFFM]Unable to create instance of type SitecoreEloquaConnector.WebFormForMarketers.Fields.CountryDrop,SitecoreEloquaConnector

这是我的代码:

namespace SitecoreEloquaConnector.WebFormForMarketers.Fields
{
    public class SafeDictionary
    {
        public string Key { get; set; }
        public string Value { get; set; }
    }

    public class CountryDrop : Sitecore.Form.Web.UI.Controls.DropList
    {
        private string _initiallySelectedCountry;

        [VisualCategory("Initial Selection")]
        [VisualFieldType(typeof(TextAreaField)), Localize]
        [VisualProperty("Initial Selection:", 100)]
        public string InitialSelection { get; set; }

        protected override void InitItems(Sitecore.Form.Web.UI.Controls.ListItemCollection items)
        {
            items.Insert(0, new ListItem("", Translate.Text("Select Country")));
            base.InitItems(items);
        }

        protected override void DoRender(HtmlTextWriter writer)
        {
            if (!string.IsNullOrEmpty(_initiallySelectedCountry))
            {
                droplist.SelectedValue = _initiallySelectedCountry;
            }
            else
            {
                droplist.SelectedIndex = 0;
            }
            base.DoRender(writer);
        }
    }
}

0 个答案:

没有答案