How to use image selector and page selector in my custom Con

Posted by Community Admin on 04-Aug-2018 06:42

How to use image selector and page selector in my custom Control in 4.1

All Replies

Posted by Community Admin on 07-Jul-2011 00:00

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

Posted by Community Admin on 07-Jul-2011 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Aug-2011 00:00

Hi Ivan,
            can you send me some sample code of ControlDesigner please.

Regards,
Pravat Sharma

Posted by Community Admin on 11-Aug-2011 00:00

Hi Pravat,

There is a sample code in our documentation and SDK.

All the best,
Ivan Dimitrov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed