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

Forums / Developing with Sitefinity / Add Property to edit window

Add Property to edit window

2 posts, 0 answered
  1. Rhyss
    Rhyss avatar
    4 posts
    Registered:
    18 Jan 2007
    07 Jul 2010
    Link to this post
    Hi all,
    i am trying to add a Rotator control to a SF project that binds to an Image Library as it's datasource.  The binding side seems to be working fine, however i am now at the point that i want to allow the user to select the Library (or enter the name) when they drop the Rotator onto the page and Edit the value.

    I must be missing something as i don't seem to be able to get the UserControl's properties to show up in the SF properties window.  It just keeps displaying the standard usercontrol options:
    Misc
    -ID
    Behavior
    -EnableViewState
    -EnableTheming
    -Visible

    I want another field Libraries.

    The code i have is:
    01.<%@ Control Language="C#" AutoEventWireup="true" CodeFile="TestRotator.ascx.cs" Inherits="TestRotator" %>
    02. 
    03.<telerik:RadRotator ID="RadRotator1" runat="server"
    04.RotatorType="ButtonsOver"  BorderWidth="4px"
    05.Width="700px"
    06.Height="400px"
    07.ScrollDirection="Left" >
    08.   <ItemTemplate>
    09. <div style="width: 300px; height: 200px;" class="person">
    10.<asp:Image ID="image1" runat="server" ImageAlign="left" AlternateText="Warden image"
    11.                                   CssClass="" Height="200px" Width="300px" />                                  
    12.                                 
    13.                                <asp:Label CssClass="" ID="CommentInfo" runat="server" ForeColor="#66FF33" Font-Size="Large">Something</asp:Label>
    14.                                 
    15.                            </div>
    16.   </ItemTemplate>
    17.</telerik:RadRotator>

    With code behind:
    01.using System;
    02.using System.Collections.Generic;
    03.using System.Linq;
    04.using System.Web;
    05.using System.Web.UI;
    06.using System.Web.UI.WebControls;
    07.using Telerik;
    08.using Telerik.Cms;
    09.using Telerik.Cms.Web;
    10.using Telerik.Web.UI;
    11.using Telerik.Caching;
    12.using Telerik.Cms.Web.UI;
    13.using System.Collections;
    14.using Telerik.Libraries;
    15.using Telerik.Cms.Engine;
    16.using System.ComponentModel;
    17. 
    18. 
    19. 
    20. 
    21. 
    22.public partial class TestRotator : System.Web.UI.UserControl
    23.{
    24.    [Browsable(false)]
    25.    [WebEditor("Telerik.Cms.Engine.WebControls.HtmlContentEditor, Telerik.Cms.Engine")]
    26.    [TypeConverter(typeof(StringConverter))]
    27.    public string Library
    28.    {
    29.        get
    30.        {
    31.            return this._library;
    32.        }
    33.        set
    34.        {
    35.            this._library = value;
    36.        }
    37.    }
    38. 
    39.    private string _library { get; set; }
    40. 
    41. 
    42. 
    43.    protected void Page_Load(object sender, EventArgs e)
    44.    {
    45.        this.Library = "Test Images";
    46.        Telerik.Libraries.LibraryManager libraryManager = new Telerik.Libraries.LibraryManager();
    47.        Guid[] parentIDArray = new Guid[1];
    48.        parentIDArray[0] = libraryManager.GetLibrary(this.Library).ID;
    49.        IList list = libraryManager.GetImages(0, 100, string.Empty, parentIDArray);
    50. 
    51. 
    52.        RadRotator1.DataSource = list;
    53.        RadRotator1.ItemDataBound += new RadRotatorEventHandler(RadRotator1_ItemDataBound);
    54.        RadRotator1.DataBind();
    55.    }
    56. 
    57.    void RadRotator1_ItemDataBound(object sender, RadRotatorEventArgs e)
    58.    {
    59. 
    60.        System.Web.UI.WebControls.Image img = e.Item.FindControl("image1") as System.Web.UI.WebControls.Image;
    61.        IContent cnt = e.Item.DataItem as IContent;
    62.        img.ImageUrl = cnt.UrlWithExtension;
    63. 
    64.        System.Web.UI.WebControls.Label lbl = e.Item.FindControl("CommentInfo") as System.Web.UI.WebControls.Label;
    65.        lbl.Text = cnt.GetMetaData("AlternateText").ToString();
    66. 
    67.    }
    68.     
    69.}

    What am i missing?

    thanks
    Jordan
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    07 Jul 2010
    Link to this post
    Hi Jordan,

    There is no selector in your control that will allow you to pick up a library or images. There is only one selector in your class HtmlContentEditor which is obsolete and you have marked it as Browsable =false.
    You need to create a custom selector that will allow you to select a whole library. I have provided sample code here. You can gather more information about custom selectors at creating_a_custom_webuitypeeditor

    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
2 posts, 0 answered