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

Forums / Deployment / how to hide tooltip for Hyper Link

how to hide tooltip for Hyper Link

5 posts, 0 answered
  1. sameer
    sameer avatar
    14 posts
    Registered:
    28 Apr 2009
    11 Jun 2009
    Link to this post
    hi
    i add Hyper Link to my page and add ImageUrl to it
    and it's working good but in case mouse over i found tooltip apper automtic and show pictuer path !
    how i can hide this tootip ?
    thank you
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Jun 2009
    Link to this post
    Hi sameer,

    There is no easy way to do this. We use SitefinityHyperLink control and the tooltip is set to returns the image url. However I came up with a custom solution that will change the tooltip.

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using Telerik.Cms.Engine.WebControls; 
    using System.Web.UI; 
    using System.ComponentModel; 
     
     
    public class CustomHyperlink : SitefinityHyperLink  
        public CustomHyperlink() 
        { 
        } 
     
        // create properties for selecting images items and setting tooltip 
        [Category("CustomProperties")] 
        [Telerik.Cms.Web.UI.WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")] 
        public string URL 
        { 
            get 
            { 
                string text = (string)this.ViewState["URL"]; 
                if (text != null
                { 
                    return text; 
                } 
                return string.Empty; 
            } 
            set 
            { 
                this.ViewState["URL"] = value; 
            } 
        } 
        [Category("CustomProperties")] 
        public string URLToolTip1 
        { 
            get 
            { 
                string text = (string)this.ViewState["URLToolTip1"]; 
                if (text != null
                { 
                    return text; 
                } 
                return string.Empty; 
            } 
            set 
            { 
                this.ViewState["URLToolTip1"] = value; 
            } 
        } 
        // override renderContents and set the url and tooltip 
        protected override void RenderContents(HtmlTextWriter writer) 
        { 
            System.Web.UI.WebControls.Image image = new System.Web.UI.WebControls.Image(); 
            image.ImageUrl = this.GetUrl(this.URL); 
            image.ToolTip = this.URLToolTip1; 
            int index = 0; 
            bool remove = false
            for ( int i = 0; i < base.Controls.Count; i++) 
            { 
                if (base.Controls[i] is System.Web.UI.WebControls.Image) 
                { 
                    remove = true
                    index = i; 
                } 
            } 
            if (remove) 
                base.Controls.RemoveAt(index); 
            image.RenderControl(writer); 
        } 
       // resolve the dynamic url here 
        private string GetUrl(string value) 
        { 
            // if our value starts with ~/   
            // we return url  
            if (value.StartsWith("~/")) 
                return this.ResolveUrl(value); 
     
     
            if (value.StartsWith("[")) 
            { 
                int idx = value.IndexOf("]"); 
                //getting the provider [Libraries]  
                string provider = value.Substring(1, idx - 1); 
                string strId = value.Substring(idx + 1); 
                Guid id = new Guid(strId); 
     
                if (Telerik.Cms.Engine.ContentManager.Providers.ContainsKey(provider)) 
                { 
                    Telerik.Cms.Engine.IContent cnt = Telerik.Cms.Engine.ContentManager.Providers[provider].GetContent(id); 
                    if (cnt != null
                        return VirtualPathUtility.ToAbsolute(cnt.UrlWithExtension, this.Context.Request.ApplicationPath); 
                } 
            } 
            return value.ToString(); 
        }  


    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. sameer
    sameer avatar
    14 posts
    Registered:
    28 Apr 2009
    14 Jun 2009
    Link to this post
    thanks Ivan
    i want to inform you i'm beginner with sitefinte i don't know what i should do by this code
    i created new class in app_Code its name CustomHyperlink.cs
    and i copy and past the code you write it into this class CustomHyperlink.cs
    but tooltip still appear
    please can you explain to me what exactly i should do by this code ?
    thank you
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 Jun 2009
    Link to this post
    Hi sameer,

    The code is custom control that you should use instead of the default SitefinityHyperLink. You should register the control in your web.config file and then use it. In the code I have created a property URLToolTip1 where you can specify desired ToolTip.

    Below is the control declaration in Sitefinity web.config file.

    <toolboxControls> 
    <clear /> 
    <add name="CustomHyperLinkControl" section="CustomControls" type="CustomHyperlink, App_Code" /> 


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  5. sameer
    sameer avatar
    14 posts
    Registered:
    28 Apr 2009
    15 Jun 2009
    Link to this post
    hi Ivan
    thanks i will try :)
Register for webinar
5 posts, 0 answered