How to use image selector and page selector in my custom Control in 4.1
Hi Team,
I have develop lot of site by using sitefinity 3.7. Now I want to use sitefinity 4.1. Below code i have used to build site header custom control in 3.7. I have a image selector and a page selector in my site header custom control. How can i achieve it on 4.1.Please help.....
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Telerik.Cms.Web.UI;
using Telerik.Cms;
using Telerik.Libraries;
using Telerik.Cms.Engine;
public partial class Sitefinity_UserControls_CustomControls_SiteHeader : System.Web.UI.UserControl
string headerImage;
Guid imageUrl;
[Category("Custom Attributes")]
[DisplayName("Image Name")]
[Description("The Guid of the image to be displayed on the header.")]
[WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")]
public string HeaderImage
get return headerImage;
set headerImage = value;
[Category("Custom Attributes")]
[DisplayName("Redirect Url")]
[Description("Index page of the header to be redirected on click of Image.")]
[WebEditor("PageIDWebEditor, App_Code")]
public Guid ImageUrl
get return imageUrl;
set imageUrl = value;
protected void Page_Load(object sender, EventArgs e)
if (imageUrl != Guid.Empty)
CmsManager cMgr = new CmsManager();
ICmsPage page = cMgr.GetPages().Cast<
ICmsPage
>().Where(x => x.ID == imageUrl).FirstOrDefault();
if (page != null)
hlHeader.NavigateUrl = page.StaticUrl;
if (!string.IsNullOrEmpty(headerImage))
LibraryManager libMgr = new LibraryManager();
headerImage = headerImage.Replace("[Libraries]", string.Empty);
IContent content = libMgr.GetContent(new Guid(headerImage));
string imgUrl = string.Empty;
if (content != null)
imgUrl = content.UrlWithExtension;
imgLogo.ImageUrl = imgUrl;
Thanks & Regards,
Pravat Sharma
Hi Pravat,
To get a selector you need to create ControlDesigner for your widget. You will find a sample implementation here.
Greetings,
Ivan Dimitrov
the Telerik team
Hi Ivan,
can you send me some sample code of ControlDesigner please.
Regards,
Pravat Sharma
Hi Pravat,
There is a sample code in our documentation and SDK.
All the best,
Ivan Dimitrov
the Telerik team