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

Forums / Developing with Sitefinity / CategoriesSelector

CategoriesSelector

4 posts, 0 answered
  1. Jay
    Jay avatar
    13 posts
    Registered:
    26 Jun 2009
    21 Jun 2010
    Link to this post
    Hello I'm trying to use your CategoriesSelector in a user control as follows:

    public partial class UserControls_News_PublishedNews : System.Web.UI.UserControl
    {
        private string[] selectedCategories;
      
        [Telerik.Cms.Web.UI.WebEditor("Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector, Telerik.Cms.Engine")]
        [TypeConverter("Telerik.Cms.Engine.WebControls.Categories.SelectedCategoriesConverter, Telerik.Cms.Engine")]
        public virtual string[] SelectedCategories
        {
            get
            {
                return selectedCategories;
                //return new string[] { "Healthcare Reform" };
            }
            set
            {
                selectedCategories = value;
            }
        }  
      
        protected void Page_Load(object sender, EventArgs e)
        {
      
        }
    }


    When I attempt to use it in page edit mode, I get the following error:

    Unable to cast object of type 'ASP.usercontrols_news_publishednews_ascx' to type 'Telerik.Cms.Engine.WebControls.Categories.ICategorizedControl'

    Am I missing something?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Jun 2010
    Link to this post
    Hello Jay,

    Try using the code below

    public partial class CustomControls_Test : System.Web.UI.UserControl, ICategorizedControl 
        protected void Page_Load(object sender, EventArgs e) 
        
        
      
        [WebEditor("Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector, Telerik.Cms.Engine")] 
        [TypeConverter("Telerik.Cms.Engine.WebControls.Categories.SelectedCategoriesConverter, Telerik.Cms.Engine")] 
        public virtual string[] SelectedCategories 
        
            get
            
                return this.selectedCategories; 
            
            set
            
                this.selectedCategories = value; 
            
        
        private string[] selectedCategories;
        #region ICategorizedControl Members 
      
        public string ProviderName 
        
            get
            
                 object obj = ViewState["ProviderName"]; 
                    if (obj != null
                        return (string)obj; 
                    return ContentManager.DefaultContentProvider; 
            
            set
            
                  this.ProviderName = value; 
            
        }
        #endregion 

    ote that this selector is obsolete. We suggest using FilterExpression instead.

    Kind regards,
    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
  3. Jay
    Jay avatar
    13 posts
    Registered:
    26 Jun 2009
    22 Jun 2010
    Link to this post
    Thank you.  It worked just fine.  But are you saying that I should no longer be using any of the selector dialogs for my user controls?  What is this FilterExpression you speak of?
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Jun 2010
    Link to this post
    Hello Jay,

    We will not remove the selector from the source, so you will be able to use it.  Generally such selectors are used when you want to get some subset of data. Since 3.6 we introduced ContentFilterBuilder class that can be used to filter any data and pass parameters to it.  I see that you are using a user control, so you could keep using the code I sent you without problems.

    Regards,
    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
Register for webinar
4 posts, 0 answered