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

Forums / General Discussions / Help with Image Field control

Help with Image Field control

6 posts, 0 answered
  1. Svetoslav
    Svetoslav avatar
    3 posts
    Registered:
    17 Sep 2012
    29 Nov 2013
    Link to this post
    Hello everyone,
    I have an image field in a designer of Sitefinity widget. What I want to do is basically to get the selected image and hide the image field on change.
    Is there such an event to attach to and hide the image field control?
    Can anyone point me in the right direction?

    Thanks,
    Svetoslav Savov ,
    The  eVeliko team.
  2. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    02 Dec 2013
    Link to this post
    Hi Svetoslav,

    You could use for example JavaScript to hide the images:
    - Add CSS class to the images, for instance 'MyClass'
    - Add JavaScriptWidget on the page you need (choose option: 'Before the closing body tag' in order to
      get all the images on the page rendered)
    - Add this code in the widget:
    function hideImage(){
      this.style.display = 'none';
    }
     
    var images = document.getElementsByClassName('MyClass');
      
    for (i in images) {
      var image = images[i];
      image.onclick = hideImage;
    };

    If this do not cover your needs, please describe more detailed your scenario.

    Regards,
    Svetoslav Manchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Svetoslav
    Svetoslav avatar
    3 posts
    Registered:
    17 Sep 2012
    04 Dec 2013
    Link to this post
    Hi Svetoslav, thanks for your response, but my problem is with the Image Field control.I will probably need to capture the event when the user selected another image, get it's url and change another image control to reflect the change.

    Attached you should find screenshots that will hopefully help you get deeper in the problem.
  4. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    05 Dec 2013
    Link to this post
    Hi Svetoslav,

    Could you please provide us more information about the control you are using and the scenario you have? Is this a custom one, created with Module builder or..? 

    Please give us some code example or the entire control code that you are using.

    Regards,
    Svetoslav Manchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Svetoslav
    Svetoslav avatar
    3 posts
    Registered:
    17 Sep 2012
    23 Jan 2014 in reply to Svetoslav Manchev
    Link to this post
    I want to use "on selected" or "image Change" event for ImageField, to set selected url to asp:Image and rebind ImageField without closing the designer.

  6. Svetoslav Manchev
    Svetoslav Manchev avatar
    735 posts
    Registered:
    07 Dec 2016
    27 Jan 2014
    Link to this post
    Hi Svetoslav,

    You could do this with JavaScript 
    What I have tested:
    - Create a widget with designer with image selector
    - Add in the ascx file a new static img element
    <img id="myImage" src="" alt="" />

    - Update in the designer .js file:
    jQuery("#previewMyImgSelector").load(function () {
                dialogBase.resizeToContent();
     
                // Implement your logic here:
                 
                var selectorImgSrc = document.getElementById("previewMyImgSelector").src;
                var myImage = document.getElementById("myImage")
                myImage.src = selectorImgSrc;
     
            });

    You could find a video demonstration how it works.

    Regards,
    Svetoslav Manchev
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered