More in this section

Forums / Developing with Sitefinity / Hiden path in linked Metafields to documents and Img

Hiden path in linked Metafields to documents and Img

2 posts, 0 answered
  1. Pierre
    Pierre avatar
    433 posts
    16 Feb 2006
    07 Jul 2008
    Link to this post

    After creating links to documents and images from Image Manager, SfLib buttonselector, or document selector we can see very long items, not very nice to see in the admin side of Modules. Can you help us to hide these long pathes with one custom solution or javascrit. Only see the filename, and hide the path is it possible ?

  2. Pepi
    Pepi avatar
    981 posts
    31 Jan 2017
    10 Jul 2008
    Link to this post
    Hello Pierre,

    I would recommend you wrap the ButtonSelector and the TextBox in a user control and implement the required functionality in it. Here is a simple example:

    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="ButtonSelectorWrapper.ascx.cs" Inherits="UserControls_Custom_Controls_ButtonSelectorWrapper" %> 
    <%@ Register TagPrefix="sfLib" Namespace="Telerik.Libraries.WebControls" Assembly="Telerik.Libraries" %> 
    <script type="text/javascript"
    function beforeInsertLink(src, altText, title, width, height)  
        if (src != '') 
            var urlHidden = document.getElementById('<%= selectedValueField.ClientID %>'); 
            if (urlHidden) 
                urlHidden.value = src
        if (title != '') 
            var urlTxt = document.getElementById('<%= urlTextBox.ClientID %>'); 
            if (urlTxt) 
                urlTxt.value = title
    <asp:TextBox ID="urlTextBox" runat="server"></asp:TextBox> 
    <sfLib:ButtonSelector ID="ButtonSelector1" AssociatedControls="selectedValueField" runat="server" /> 
    <asp:HiddenField runat="server" ID="selectedValueField" /> 


    public partial class UserControls_Custom_Controls_ButtonSelectorWrapper : System.Web.UI.UserControl, ITextControl 
        protected void Page_Load(object sender, EventArgs e) 
        #region ITextControl Members 
        public string Text 
                return this.selectedValueField.Value; 
                int lastIndex = value.LastIndexOf('/'); 
                if (lastIndex != -1) 
                    string fileName = value.Substring(lastIndex + 1); 
                    if (fileName.EndsWith(".sflb")) 
                        this.urlTextBox.Text = HttpUtility.UrlDecode(fileName.Replace(".sflb""")); 
                this.selectedValueField.Value = value; 

    Note, that you need to keep the real value in a hidden field.

    Hope this helps.

    Kind regards,
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
2 posts, 0 answered