我正在创建自定义下拉列表字段,因为我需要为我的下拉列表设置初始值。我已经在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);
}
}
}