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

Forums / Developing with Sitefinity / Custom Files Selector

Custom Files Selector

9 posts, 1 answered
  1. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    17 Mar 2010
    Link to this post
    Hi All,

    I have been trying to implement a custom files selector option on the LibraryItemEdit.ascx page by adding the following code to that page.

     

    <li class="selector">
        <asp:label id="lblSubtitleFile" runat="server" associatedcontrolid="SubtitleFile" text="<%$Resources:SubtitleFile %>"></asp:label>
        <asp:textbox runat="server" id="SubtitleFile"></asp:textbox>
        <sflib:buttonselector id="ButtonSelector2" windownavigateurl="~/Estate/UserControls/Admin/FilesSelector.aspx" associatedcontrols="Thumbnail" itemtemplatepath="~/Sitefinity/Admin/ControlTemplates/News/Dialogs/ButtonSelector.ascx" runat="server" cssclass="pickerWrapper" buttontext="<%$Resources:Select%>" />
        <p class="example">
            <asp:literal id="litSubtitleFileNote" runat="server" text="<%$Resources:SubtitleFileNote %>"></asp:literal></p>
    </li>

     


    Then I created the FilesSelector.aspx file as follows.

     

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="FilesSelector.aspx.cs" Inherits="FilesSelector" %>
    <%@ Register Namespace="AdminControls" TagPrefix="econtrols" %>
      
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
    <head runat="server">
        <title>Select a file</title>
        <link type="text/css" rel="stylesheet" href="~/Sitefinity/UserControls/Dialogs/CustomDialogs.css" />
        <link type="text/css" rel="stylesheet" href="~/Sitefinity/Admin/Themes/Default/CustomDialogs.css" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <telerik:radscriptmanager id="RadScriptManager1" runat="server" />
            <econtrols:FilesSelector ID="FilesSelector1" runat="server"></econtrols:FilesSelector>
          
        </div>
        </form>
    </body>
    </html>

    So far so good. Clicking on the select button opens the window. For the FilesSelector tag I use the following class in the app_code directory.

    namespace AdminControls
    {
        using System;
        using System.Collections.Generic;
        using System.Linq;
        using System.Web;
      
        /// <summary>
        /// Summary description for FilesSelector
        /// </summary>
        public class FilesSelector: Telerik.Cms.Web.UI.Dialogs.PagesSelector
        {
              
        }
    }

    As you can see nothing special. What I am looking for is a way to override the "standard template" used by the PagesSelector class. I tried this by overriding the LayoutTemplatePath property but that had no effect. Am I doing something wrong?

    Regards,


    David
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Mar 2010
    Link to this post
    Hello David van Geel,

    The button selector allows you to get items from the file system and Images and Documents module. I am not sure why you are trying to add page selector in this way. If you want to use page selector you can set the WindowNavigateUrl value to ~/Sitefinity/UserControls/Dialogs/PagesSelector.aspx

    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. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    18 Mar 2010
    Link to this post
    Hi Ivan,

    I was looking for a selector which displayed files on the file system and allowed upload to the file system. The "files' tab of the PagesSelector looked the most like what I was looking for. The reason why I am trying to override the "standard" template of the PagesSelector class is to have the pages tab not displayed.

    Regards,


    David
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    18 Mar 2010
    Link to this post
    Hello David van Geel,

    You can create a custom class that inherits from ItemSelector and there override CreateChildControls as shown below

    public class CustomSelectorDialog : ItemSelector
    {
        public CustomSelectorDialog()
        {
        }
     
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            this.container.TabStrip.Tabs[0].Visible = false;
            this.container.TabStrip.Tabs[1].Visible = false;
            this.container.TabStrip.SelectedIndex = 2;
            this.container.TabStrip.MultiPage.SelectedIndex = 2;
     
        }
     }


    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.
    Answered
  5. David van Geel
    David van Geel avatar
    59 posts
    Registered:
    19 Aug 2009
    18 Mar 2010
    Link to this post
    Hi Ivan,

    This works like a charm! Thanks.

    Regards,


    David
  6. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    10 Nov 2010
    Link to this post
    hi ,

    i am facing some problem in custom selector. i want to only the page tab is visible. from below code only page tab is visible,so this is fine. my problem is that when dialog box open, done button(i 'm done) is always disable. so i am not able to insert the selected page link to my url text box.

    i create a custom class that inherits from ItemSelector and there override CreateChildControls as shown below


    using System.Web.UI;<br>
    using System.Web.UI.HtmlControls;<br>
    using System.Web.UI.WebControls;<br>
    using System.Web.UI.WebControls.WebParts;<br>
    using System.Xml.Linq;<br>
    using Telerik.Libraries.WebControls;<br>
    <br>
    namespace AdminControls<br>
    {<br>
        public class CustomSelectorDialog : ItemSelector<br>
        {<br>
            public CustomSelectorDialog()<br>
            {<br>
            }<br>
    <br>
            protected override void CreateChildControls()<br>
            {<br>
                base.CreateChildControls();<br>
                //this.container.TabStrip.Tabs[0].Visible = true;<br>
                this.container.TabStrip.Tabs[0].TabStrip.Tabs[0].Visible = true;<br>
                this.container.TabStrip.Tabs[0].TabStrip.Tabs[1].Visible = false;<br>
                this.container.TabStrip.Tabs[0].TabStrip.Tabs[2].Visible = false;<br>
                this.container.TabStrip.Tabs[0].TabStrip.Tabs[0].Selected = true;<br>
                //this.container.TabStrip.Tabs[1].Visible = false;<br>
                //this.container.TabStrip.SelectedIndex = 1;<br>
                //this.container.TabStrip.MultiPage.SelectedIndex = 1;<br>
                <br>
    <br>
    <br>
    <br>
            }<br>
    <br>
    <br>
        }<br>
    }<br>

    any help regarding this is appreciated. i am using community edition version 3.7

    thanks
  7. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    10 Nov 2010
    Link to this post
    Hi humayoo,

    The problem is that when you click on a RadTreeView node there is not onclick function that makes a back  call to Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx and the "I'm Done" button remains disabled.

    Options

    1. Modify  Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx and add the js function that gets the selected node and enable "I'm Done" button. Then return the value to the main window

    function SelectValue(sender, eventArgs) {
        switchClasses(1, "show", "hidden", 'doneActions');
        switchClasses(1, "hidden", "show", 'actionsDisabled');
        var node = eventArgs.get_node().get_attributes().getAttribute('PageUrl');
        alert(node);
    }


    2. Create a custom web editor

    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
  8. humayoo
    humayoo avatar
    89 posts
    Registered:
    25 Oct 2010
    11 Nov 2010
    Link to this post
    Hi,

    thanks for reply. now button is active. i am new to sitefinity.  you told that Then return the value to the main window and create custom editor.

    my question is that

    1. how to return the value to main window and insert the link to my required text box. if possible provide complete example.

    2. you wrote that i have to create custom editor but  Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx has already this editor cmsUrlWebEditor

    thanks
    Humayoo
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Nov 2010
    Link to this post
    Hi humayoo,

    1. how to return the value to main window and insert the link to my required text box. if possible provide complete example.

    You can take a look at custom web editor  which illustrates this behavior. Here is a demo that illustrates how to return the values from RadWindow.

    2. you wrote that i have to create custom editor but  Sitefinity\Admin\ControlTemplates\Libraries\Dialogs\ItemSelector.ascx has already this editor cmsUrlWebEditor

    Yes you can replace the default CmsUrlWebEditor in the template, but you can work with java script only and return the value of the selected item to the main window. As you can see in the previous sample the variable "node" returns the url of the selected item.

    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
9 posts, 1 answered