Hi Victor,
1. Add the following code in the control designer template
2. Add the following code in the control designer class
protected override void InitializeControls(Web.UI.GenericContainer container)
{
var resources = Res.Get<Labels>();
ContentSelector.TitleText = resources.SelectItem;
ContentSelector.ItemType = typeof(MyType).FullName;
ContentSelector.ServiceUrl = "~/Sitefinity/Services/Content/MyService.svc/";
btnSelectSingleItem.Text = "select a single item";
}
public override IEnumerable<ScriptDescriptor> GetScriptDescriptors()
{
var scriptDescriptors = new List<ScriptDescriptor>(base.GetScriptDescriptors());
var desc = (ScriptControlDescriptor)scriptDescriptors.Last();
desc.AddProperty("_selectContentButton", btnSelectSingleItem.ClientID);
desc.AddComponentProperty("contentSelector", ContentSelector.ClientID);
return scriptDescriptors.ToArray();
}
/// <summary>
/// Gets a collection of <see cref="T:System.Web.UI.ScriptReference"/> objects that define script resources that the control requires.
/// </summary>
/// <returns>
/// An <see cref="T:System.Collections.IEnumerable"/> collection of <see cref="T:System.Web.UI.ScriptReference"/> objects.
/// </returns>
public override IEnumerable<System.Web.UI.ScriptReference> GetScriptReferences()
{
var res = new List<ScriptReference>(base.GetScriptReferences());
var assemblyName = this.GetType().Assembly.GetName().ToString();
res.Add(new ScriptReference(designerScriptName, assemblyName));
return res.ToArray();
}
protected override string LayoutTemplateName
{
get
{
return ContentCustomDesigner.designerTemplate;
}
}
protected virtual LinkButton btnSelectSingleItem
{
get
{
return this.Container.GetControl<LinkButton>("btnSelectSingleItem", true);
}
}
protected virtual ContentSelector ContentSelector
{
get
{
return this.Container.GetControl<ContentSelector>("selector", true);
}
}
3. Add the code below to the client component
Telerik.Sitefinity.Samples.ContentBlockCustomDesigner = function (element) {
// element
this._contentSelector = null;
this._selectContentButton = null;
this._showContentSelectorDelegate = null;
Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.initializeBase(this, [element]);
}
Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.prototype = {
initialize: function () {
Telerik.Sitefinity.Samples.ContentBlockCustomDesigner.callBaseMethod(this, 'initialize');
this._showContentSelectorDelegate = Function.createDelegate(this, this._showContentSelector);
$addHandler($get(this._selectContentButton), "click", this._showContentSelectorDelegate);
},
dispose: function () {
if (this._showContentSelectorDelegate) {
$removeHandler($get(this._selectContentButton), "click", this._showContentSelectorDelegate);
delete this._showContentSelectorDelegate;
}
},
get_contentSelector: function () {
return this._contentSelector;
},
set_contentSelector: function (value) {
this._contentSelector = value;
},
get_selectContentButton: function () {
return this._selectContentButton;
},
set_selectContentButton: function (value) {
this._selectContentButton = value;
},
_showContentSelector: function () {
this.get_contentSelector().dataBind();
jQuery(this.get_element()).find('#selectorTag').show();
dialogBase.resizeToContent();
},
refreshUI: function () {
},
// forces the designer to apply the changes on UI to the cotnrol Data
applyChanges: function () {
var data = this.get_controlData();
}
}
Regards,
Ivan Dimitrov
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>