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;
;
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
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
=
""
/>
jQuery(
"#previewMyImgSelector"
).load(
function
()
dialogBase.resizeToContent();
// Implement your logic here:
var
selectorImgSrc = document.getElementById(
"previewMyImgSelector"
).src;
var
myImage = document.getElementById(
"myImage"
)
myImage.src = selectorImgSrc;
);