+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / ImageSelector using pre-selected library?

ImageSelector using pre-selected library?

2 posts, 0 answered
  1. Connections Academy Developer
    Connections Academy Developer avatar
    151 posts
    Registered:
    04 May 2005
    19 Feb 2010
    Link to this post
    I've implemented ImageSelector like this, and it works great.

    [WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")]
    public string MyImage { get; set; }
     
    public string ProviderName {
        get { return MyImage.ProviderName; }
        set { MyImage.ProviderName = value; }
    }

    However, when the ImageSelector is used, I'd like one specific library to show instead of all of them. Is there a way to do that?

    Thanks!
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    19 Feb 2010
    Link to this post
    Hello Connections Academy Developer,

    You need to create a custom selector or override the existing one. You can create a custom selector that inherits from ImageSelector. Then override CreateChildControls() and do not call the base. Create a custom method to bind the libraries

    sample code

    protected override void CreateChildControls()
            {
               ...
                       ....
     
                switch (this.Mode)
                {
                    case DisplayMode.LibrariesView:
                        this.CreateLibrariesView();
                        break;
                    case DisplayMode.ItemsView:
                        this.CreateItemsView();
                        break;
                }
     
                if (base.HostControl != null)
                {
                    this.container.ButtonsHolder.Visible = false;
                    this.container.UnresolvedValue.ValueChanged += new EventHandler(UnresolvedValue_ValueChanged);
                }
            }
     
     
    protected void CreateLibrariesView()
            {
               // CREATE DATASOURCE FOR LIBRARIES AND ITEMS
     
                this.container.LibrariesRepeater.ItemCreated += new RepeaterItemEventHandler(LibrariesRepeater_ItemCreated);
                this.container.LibrariesRepeater.DataSource = odsLibs;
                this.container.LibrariesRepeater.DataBind();
            }
     
     
          private DisplayMode Mode
            {
                get
                {
                    return this.mode;
                }
                set
                {
                    this.mode = value;
                    this.selectedTabIndex = container.TabStrip.SelectedIndex;
                    this.ChildControlsCreated = false;
                }
            }


    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
2 posts, 0 answered