+1-888-365-2779
Try Now
More in this section
Categories
Bloggers
Blogs RSS feed

Working with selectors Part One: Content selector, Image selector, Document selector.

by Ivan Dimitrov

 

I'm going to start a session of some posts about selectors in Sitefinity. There won't be a lot of coding, because I will describe some general aspects of the topic. In this post I will work with user control and selectors will be set as a properties of this control.

We will define selectors in the code behind of our user control.

1. Content selector.

 WebEditor1

Content Selector

As a result the Guid of a selected item will be returned. You can browse from Generic_Content, News,

Blogs, Images and Documents, Events.

#region Properties
 
 //content selector 
    [WebEditor("Telerik.Cms.Engine.WebControls.ContentSelector, Telerik.Cms.Engine")]
 public Guid SelectContent
    {
 get 
        {
 return this.selectContent;
        }
 set 
        {
 this.selectContent = value;
        }
    }
 //declare Provider Name property 
 public virtual string ProviderName
    {
 get 
        {
 return this.providerName;
        }
 set 
        {
 this.providerName = value;
        }
    }
 
 private Guid selectContent;
 private string providerName = string.Empty;
 
#endregion

 

2. Image and document selectors

 

WebEditor2

Image selector

 

WebEditor3

Document Selector

 

 //image selector 
    [WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")]
 public string SelectImage
    {
 get 
        { return this.image; }
 set 
        { this.image = value; }
    }
 private string image;
 
 //document selector 
   [WebEditor("Telerik.Libraries.WebControls.DocumentsSelector, Telerik.Libraries")]
 public string SelectDoc
    {
 get 
        { return this.doc; }
 set 
        { this.doc = value; }
    }
 private string doc;

 

selector1

 

Coming soon Part 2 - file manager selector, page id selector, rss feed selector

8 comments

Leave a comment
  1. Priti Jan 08, 2009
    Very usefull post. Thanks Ivan
    I have one query about ContentSelector eidtor. Here using dropdown we can select content of type Generic Content, News, Blogs, Images and Documents, Events, etc. Basically contents from all the Generic Content Based modules. Now if I want to restrict the user to News items only. Can I do this? I mean dropdown should only show News. Or atleast News should be selected by default. Is it possible? and How?
  2. Seth Jan 13, 2009
    Extremely useful post. We find that content managers will often change the name of an image or document effectively break the link these 2 selectors return. Is there anyway to have the Image and Doc selectors to a return a Guid so that this doesn't happen? Thanks
  3. Andrei Jan 15, 2009
    I am trying this in VB and it does not work. What are you importing? Anything else I need to be aware of? Thanks
  4. Jay Buys Apr 27, 2009
    I'm trying to do something similar with a custom control that I'm building.  I'm using the ImageSelector WebEditor but it always returns the GUID of the image and not the actual  URL like you have here.  I'm using 3.6 SP1.  Has something changed in the new version that affects this?
  5. Jay Buys Apr 28, 2009
    For anyone else having the problem I noted above... It's been solved... see this forum post - http://www.sitefinity.com/support/forums/support-forum-thread/b1043S-camdhh.aspx - Thanks to the Sitefinity team for always responding so quickly.
  6. Truman Feb 16, 2010
    Every time I try selecting another content type (from Generic to News or Events or Blogs, etc) I consistently get this blog error.. no matter which content type I'm trying to grab. Any ideas on what this is??

    Multiple controls with the same ID 'BlogsDataSource' were found. FindControl requires that controls have unique IDs.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Web.HttpException: Multiple controls with the same ID 'BlogsDataSource' were found. FindControl requires that controls have unique IDs.
  7. Ivan Dimitrov Feb 28, 2010
    Take a look at this post

    http://www.sitefinity.com/support/forums/sitefinity-3-x/developing-with-sitefinity/webeditors-inside-radwindow-and-callback.aspx
  8. James Mar 07, 2016
    Thanks for the post!

    Leave a comment