More in this section
Forums / Developing with Sitefinity / Allow user to select a single category

Allow user to select a single category

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
4 posts, 0 answered
  1. UI Crew
    UI Crew avatar
    151 posts
    27 Sep 2012
    18 Dec 2008
    Link to this post

    I have a generic content provider called "Data". In a user control I have a property called "SelectedCategory" and want to allow the content manager to select a single category from the list of categories in the Data provider.

    Is there a WebEditor that allows this and how can I use it.

  2. Pepi
    Pepi avatar
    981 posts
    31 Jan 2017
    18 Dec 2008
    Link to this post
    Hi Seth Cleaver,

    Sitefinity does not provide a selector for choosing a single category. We would suggest you use CategoriesSelector property editor that lets the user choose more that one categories:

    [WebEditor("Telerik.Cms.Engine.WebControls.Categories.CategoriesSelector, Telerik.Cms.Engine")] 
    [TypeConverter("Telerik.Cms.Engine.WebControls.Categories.SelectedCategoriesConverter, Telerik.Cms.Engine")] 
    public virtual string[] SelectedCategories 
            return selectedCategories; 
            selectedCategories = value; 

    Actually, you could achieve the required functionality (to select a single category) by implementing the following javascript function in the CategoriesSelector template (\[Project_Name]\Sitefinity\Admin\ControlTemplates\Generic_Content\CategoriesSelector.ascx):

    <h4 class="multyhead">Categories selector</h4> 
    <div class="selectedItems" id="availableItems"
    <asp:GridView ID="categoriesList" runat="server" AutoGenerateColumns="false" AllowPaging="false" GridLines="None" ShowHeader="false"
                    <asp:CheckBox ID="categorySelectedCheckbox" runat="server" onclick="selectChkBox('availableItems', this);" /> 
                <ItemStyle CssClass="gridActionsSelectCategory" /> 
            <asp:BoundField DataField="CategoryName" SortExpression="CategoryName" HeaderText='<%$Resources:Category %>' /> 
    <script language="javascript"
    function selectChkBox(availableItems, obj) 
        var availableTags = document.getElementById(availableItems); 
        var tagList = availableTags.getElementsByTagName("input"); 
        for (i = 0; i < tagList.length; i++) { 
          tagList[i].checked = false
        obj.checked = true

    Hope this helps.

    Sincerely yours,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Devin
    Devin avatar
    149 posts
    09 Jun 2009
    09 Jun 2010
    Link to this post
    Hi Pepi,
    Is there a similar control for News categories?

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    12 Sep 2017
    09 Jun 2010
    Link to this post
    Hi Devin,

    You need to create a custom WebUITypeEditor and get the categories by provider using GetCategories method of the manger.

    Sincerely yours,
    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