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

Forums / Developing with Sitefinity / How to add User Control

How to add User Control

12 posts, 0 answered
  1. Vanitha
    Vanitha avatar
    7 posts
    Registered:
    06 Oct 2010
    08 Oct 2010
    Link to this post
    Hi All,

    How to upload asp.net user control(.ascx file) . And how to use that uploaded control in a new page. In the online site I checked there is an option for uploading control in sitefinity 3.6 version. But how to do this in sitefinity 4.0 version.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Oct 2010
    Link to this post
    Hi Vanitha,

    Please watch this video.

    Best wishes,
    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. Vanitha
    Vanitha avatar
    7 posts
    Registered:
    06 Oct 2010
    08 Oct 2010
    Link to this post
    Thanks for quick response. I will watch
  4. Vanitha
    Vanitha avatar
    7 posts
    Registered:
    06 Oct 2010
    08 Oct 2010
    Link to this post
    I downloaded  the trial version of sitefinity 4.0 , I didn't find the upload control link while creating page.
  5. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    08 Oct 2010
    Link to this post
    Hi Vanitha,


    The thread you are using is for Sitefinity 3.x editions. In Sitefinity 4.0 this option is not implemented yet. You might find this article useful.

    Greetings,
    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
  6. Vanitha
    Vanitha avatar
    7 posts
    Registered:
    06 Oct 2010
    08 Oct 2010
    Link to this post
    oh ok thanks
  7. Johar Iqbal
    Johar  Iqbal avatar
    10 posts
    Registered:
    20 Aug 2009
    28 Oct 2010
    Link to this post
    How can I add my custom control to sitefinity 4.0. I followed the one(http://www.sitefinity.com/40/help/developer-manual/controls-adding-a-new-control.html) but not worked for me. Also the cs file not uploading as it did in Sitefinity 3.7.
  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Oct 2010
    Link to this post
    Hello Johar ,

    There is no option to upload a control in Sitefinity BETA 2. We will have this feature in a later stage. There should not be a problem to register your control following Adding a new control article. Please check whether the control type is correct and restart the application.

    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
  9. Johar Iqbal
    Johar  Iqbal avatar
    10 posts
    Registered:
    20 Aug 2009
    28 Oct 2010
    Link to this post
    I want to add the RotatorSlideshow control to 4.0, but couldn't succeed. it was working fine in my 3.7.

    Love sitefinity..
  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Oct 2010
    Link to this post
    Hello Johal ,

    Could you send the control you are trying to plug? We do not have a control called "RotatorSlideshow".

    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
  11. Johar Iqbal
    Johar  Iqbal avatar
    10 posts
    Registered:
    20 Aug 2009
    28 Oct 2010
    Link to this post
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Web.UI.HtmlControls;
    using Telerik.Cms.Web.UI;
    using Telerik.Cms.Engine;
    using Telerik.Libraries;
    using System.Text;
    using Telerik.Web.UI;
     
    public partial class UserControls_My_Controls_rotatorSlideshow : System.Web.UI.UserControl
    {
     
        #region Description
     
        // This control has been developed for use with Sitefinity
        // by Ben Bruner of Web Spot Media Group (http://webspotmedia.com).
        //
        // This control will allow you to select one of your Image Libraries
        // and display it using a Telerik RadRotator Control.
        // You may also select one of the several built in Skins and Slide Direction.
        //
        // This will also apply the included stylesheet if you would like to apply some
        // custom styles to the elements.
        //
        // You may choose to use the features of 'Name' and 'Caption' if you would like
        // to add labels into the RadRotator Template and Bind them to the properties.
     
        #endregion
     
        #region Set Properties
     
        /// <summary>
        /// Gets or sets the library to use.
        /// </summary>
        /// <value><c>true</c> if [use internal CSS]; otherwise, <c>false</c>.</value>
        [Browsable(true),
         Category("Default"),
         DisplayName("Image Library Name"),
         Description("Which Image Libary from Images & Documents should be used.")]
        public string ImageLibraryName { get; set; }
     
        /// <summary>
        /// Gets or sets the slideshow speed.
        /// </summary>
        /// <value>The Speed of the library in seconds.</value>
        [Browsable(true),
         Category("Default"),
         DisplayName("Speed of Slideshow (secs)"),
         Description("The Speed of the slideshow in Seconds.")]
        public int SlideshowSpeed { get; set; }
     
        /// <summary>
        /// Pause on Mouseover.
        /// </summary>
        /// <value>Pause on Mouseover.</value>
        [Browsable(true),
         Category("Behavior"),
         DisplayName("Pause on Mouseover"),
         Description("Set to true if the slideshow should stop when mouse is over.")]
        public bool PauseOnMouseOver { get; set; }
     
        /// <summary>
        /// Choose Skin.
        /// </summary>
        /// <value>Choose the skin to use.</value>
        [Browsable(true),
         Category("Appearance"),
         DisplayName("Select Skin"),
         Description("Select the Skin for your player. Only applies to certain Player Types.")]
        public PlayerSkin Skin { get; set; }
     
        public enum PlayerSkin { Black, Default, Forest, Hay, Office2007, Outlook, Simple, Sunset, Telerik, Vista, Web20, WebBlue }
     
        /// <summary>
        /// Choose Rotator Type.
        /// </summary>
        /// <value>Choose Rotator Type.</value>
        [Browsable(true),
         Category("Behavior"),
         DisplayName("Player Type"),
         Description("Choose how you would like the slideshow displayed and cycled through.")]
        public PlayerType RotatorType { get; set; }
     
        public enum PlayerType { AutomaticAdvance, ButtonsOver, Buttons, Slideshow, SlideshowButtons }
     
        /// <summary>
        /// Direction to Scroll.
        /// </summary>
        /// <value>Direction to scroll.</value>
        [Browsable(true),
         Category("Behavior"),
         DisplayName("Scroll Direction"),
         Description("What direction would you like your images to scroll.")]
        public DirectionScroll ScrollDirection { get; set; }
     
        public enum DirectionScroll { Left, Right, Up, Down }
     
        /// <summary>
        /// Height of RadRotator.
        /// </summary>
        /// <value>Height of RadRotator in px.</value>
        [Browsable(true),
         Category("Appearance"),
         DisplayName("Height(px)"),
         Description("Height of the Control in pixels.")]
        public int Height { get; set; }
     
        ///// <summary>
        ///// Height of items in RadRotator.
        ///// </summary>
        ///// <value>Height of Items inside the RadRotator Control.</value>
        //[Browsable(true),
        // Category("Appearance"),
        // DisplayName("Image Height(px)"),
        // Description("Height of the images displayed in the control in pixels.")]
        //public int ItemHeight { get; set; }
     
        /// <summary>
        /// Width of RadRotator.
        /// </summary>
        /// <value>Width of RadRotator in px.</value>
        [Browsable(true),
         Category("Appearance"),
         DisplayName("Width(px)"),
         Description("Width of the Control in pixels.")]
        public int Width { get; set; }
     
        ///// <summary>
        ///// Width of items in RadRotator.
        ///// </summary>
        ///// <value>Width of Items inside the RadRotator Control.</value>
        //[Browsable(true),
        // Category("Appearance"),
        // DisplayName("Image Width(px)"),
        // Description("Wdith of the images displayed in the control in pixels.")]
        //public int ItemWidth { get; set; }
     
     
     
        #endregion
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
     
                List<ImageGalleryItem> slides = new List<ImageGalleryItem>();
                LibraryManager libMgr = new LibraryManager();
     
                if (ImageLibraryName != null)
                {
     
                    // ILibrary lib = libMgr.GetLibrary("Photo Gallery");
                    ILibrary lib = libMgr.GetLibrary(ImageLibraryName);
                    if (lib != null)
                    {
                        IList libItems = lib.GetItems();
     
                        foreach (IContent item in libItems)
                        {
                            slides.Add(new ImageGalleryItem()
                            {
                                Url = item.UrlWithExtension,
                                Name = item.GetMetaData("Name") as string,
                                Caption = item.GetMetaData("AlternateText") as string
                            });
                        }
                    }
                    imageRotator.DataSource = slides;
                   // imageRotator.ItemDataBound += new RadRotatorEventHandler(imageRotator_ItemDataBound);
                    imageRotator.DataBind();
                    
           
                    //Set Speed
                    int SpeedInMilliSeconds = SlideshowSpeed * 1000;
                    imageRotator.FrameDuration = SpeedInMilliSeconds;
     
                    //Pause On Mouseover
                    imageRotator.PauseOnMouseOver = PauseOnMouseOver;
     
                    //Skin
                    imageRotator.Skin = Skin.ToString();
     
                    //Rotator Type
                    Telerik.Web.UI.RotatorType MyRotatorType = new Telerik.Web.UI.RotatorType();
                    switch (RotatorType)
                    {
                        case PlayerType.AutomaticAdvance:
                            MyRotatorType = Telerik.Web.UI.RotatorType.AutomaticAdvance;
                            break;
                        case PlayerType.Buttons:
                            MyRotatorType = Telerik.Web.UI.RotatorType.Buttons;
                            break;
                        case PlayerType.ButtonsOver:
                            MyRotatorType = Telerik.Web.UI.RotatorType.ButtonsOver;
                            break;
                        case PlayerType.Slideshow:
                            MyRotatorType = Telerik.Web.UI.RotatorType.SlideShow;
                            break;
                        case PlayerType.SlideshowButtons:
                            MyRotatorType = Telerik.Web.UI.RotatorType.SlideShowButtons;
                            break;
                        default:
                            MyRotatorType = Telerik.Web.UI.RotatorType.AutomaticAdvance;
                            break;
                    }
                    imageRotator.RotatorType = MyRotatorType;
     
                    //Scroll Direction
                    Telerik.Web.UI.RotatorScrollDirection MyScrollDirection = new Telerik.Web.UI.RotatorScrollDirection();
                    switch (ScrollDirection)
                    {
                        case DirectionScroll.Up:
                            MyScrollDirection = Telerik.Web.UI.RotatorScrollDirection.Up;
                            break;
                        case DirectionScroll.Down:
                            MyScrollDirection = Telerik.Web.UI.RotatorScrollDirection.Down;
                            break;
                        case DirectionScroll.Left:
                            MyScrollDirection = Telerik.Web.UI.RotatorScrollDirection.Left;
                            break;
                        case DirectionScroll.Right:
                            MyScrollDirection = Telerik.Web.UI.RotatorScrollDirection.Right;
                            break;
                        default:
                            MyScrollDirection = Telerik.Web.UI.RotatorScrollDirection.Right;
                            break;
                    }
                    imageRotator.ScrollDirection = MyScrollDirection;
     
                    //Set Dimensions
                    imageRotator.Height = Height;
                    imageRotator.Width = Width;
                    //imageRotator.ItemHeight = ItemHeight;
                    //imageRotator.ItemWidth = ItemWidth;
     
                    //Display Style Sheet
                    DisplayStyleSheet();
                }
     
            }
        }
     
     
        void imageRotator_ItemDataBound(object sender, RadRotatorEventArgs e)
        {
     
            System.Web.UI.WebControls.Image img = e.Item.FindControl("image1") as System.Web.UI.WebControls.Image;
            IContent cnt = e.Item.DataItem as IContent;
            img.ImageUrl = cnt.UrlWithExtension;
        }
        /// <summary>
        /// Represents an item in a Sitefinity image gallery
        /// </summary>
        public class ImageGalleryItem
        {
            public string Url { get; set; }
            public string Name { get; set; }
            public string Caption { get; set; }
        }
     
        private void DisplayStyleSheet()
        {
            string path = AppRelativeVirtualPath.Substring(0, AppRelativeVirtualPath.LastIndexOf('/') + 1);
            string CssPath = path + "Slideshow.css";
            RegisterCss(CssPath);
        }
     
        private void RegisterCss(string cssUrl)
        {
            var link = new HtmlLink();
            link.Href = cssUrl;
            link.Attributes.Add("type", "text/css");
            link.Attributes.Add("rel", "stylesheet");
            Page.Header.Controls.Add(link);
        }
    }


    ASCX is here Below

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="rotatorSlideshow.ascx.cs"
        Inherits="UserControls_My_Controls_rotatorSlideshow" %>
    <div id="center">
        <div class="Rotator">
            <telerik:RadRotator ID="imageRotator" ItemWidth="653px"    runat="server"  FrameDuration="7000" PauseOnMouseOver="False"
                Skin="Sunset">
                <ItemTemplate>
                    <asp:Image style=" background-position:center center; max-height:400px; max-width:800px; min-height:310px; min-width:653px;" ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Url") %>' />
                </ItemTemplate>
            </telerik:RadRotator>
            <div class="RotatorControl">
                <a href="#" onclick="($find('<%= imageRotator.ClientID %>')).showNext(Telerik.Web.UI.RotatorScrollDirection.Right);return false;"
                    class="RotatorPrev"></a><a href="#" onclick="($find('<%= imageRotator.ClientID %>')).pause();
                                    this.style.display = 'none';
                                    document.getElementById('<%= imageRotator.ClientID %>Start').style.display='block';
                                    return false;" class="RotatorStop" id="<%= imageRotator.ClientID %>Stop">
                    </a><a href="#" onclick="($find('<%= imageRotator.ClientID %>')).resume(); this.style.display = 'none';        
                                    document.getElementById('<%= imageRotator.ClientID %>Stop').style.display='block';return false;"
                        class="RotatorStart" id="<%= imageRotator.ClientID %>Start"></a><a href="#" onclick ="($find('<%= imageRotator.ClientID %>')).showNext(Telerik.Web.UI.RotatorScrollDirection.Left);return false;"
                            class="RotatorNext"></a>
                <!-- <a id="A1" href="~/Photos.aspx"  class="ViewGallery"><img src="./App_Themes/ModernLight/Rotator/HomePage/hrViewGallery.gif" height="13" width="80" alt="" /></a>-->
            </div>
        </div>
    </div>
     
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Oct 2010
    Link to this post
    Hi Johar ,

    The managers and objects you use do no exists in Sitefinity 4.0. You have to use the new classes LibrariesManager, Telerik.Sitefinity.Libraries.Model.Image, Telerik.Sitefinity.Fluent.Content.Albums facade.

    sample

    var libMgr = new Telerik.Sitefinity.Modules.Libraries.LibrariesManager();
    var allImages = libMgr.GetImages();
    foreach (Telerik.Sitefinity.Libraries.Model.Image img in allImages)
    {
        var title = img.Title;
        var alt = img.AlternativeText;
        var url = img.UrlName;
    }


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