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

Forums / Developing with Sitefinity / Adding a Selector Control to the Image control to make it a linkbutton

Adding a Selector Control to the Image control to make it a linkbutton

2 posts, 0 answered
  1. Terry
    Terry avatar
    1 posts
    Registered:
    07 Apr 2009
    18 Nov 2009
    Link to this post
    Maybe I'm missing something, but when I use the image control to place an image in a page container, I do not have the ability to make that image clickable.  I would like to extend the control to have the ability to select a document, site page or external web page and have the image be a clickable image.  I see where you have done something like this for other controls.  As a work-around, I have been doing this functionality using the Generic Content control and surrounding the image with an anchor tag but it would be nice for the content managers of my site to be able to just drag an image control to a container and fill in the information using the built-in wizard of the control.  Currently we are using version 3.6 of Sitefinity.

    Thank you,

    Terry
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    18 Nov 2009
    Link to this post
    Hi Terry,

    You need to create a simple user or custom control that uses HyperLink control. You should create a several public properties to set the value of the Image, Document, Url, Text etc as shown below:

    public string ExtUrl
        {
            get
            {
                return this.extUrl;
            }
            set
            {
                this.extUrl = value;
            }
        }
     
     
        [WebEditor("Telerik.Libraries.WebControls.ImageSelector, Telerik.Libraries")]
        public string ImgUrl
        {
            get
            {
                return this.img;
            }
            set
            {
                this.img = value;
            }
        }
        
     
        [WebEditor("Telerik.Libraries.WebControls.DocumentsSelector, Telerik.Libraries")]
        public string DocUrl
        {
            get
            {
                return this.docUrl;
            }
            set
            {
                this.docUrl = value;
            }
        }
     
        private string extUrl;
        private string img;
        private string docUrl;

    Then on Page_Load you need to set the properties to the value of our public properties as a value of Hyperlink control properties. Note that some of the selectors return dynamic link ( [ProviderName]Guid) that you have to resolve. More information about url resolving at how to resolve dynamic links in Sitefinity

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
2 posts, 0 answered