Help with Image Field control - General Discussions - General Discussions - Progress Community
 General Discussions

Help with Image Field control

  • Help with Image Field control
  • 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.
  • 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
  • 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.

  • 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
  • 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.

  • 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