I'm using the image gallery as per this example http://demos.telerik.com/aspnet-ajax/image-gallery/examples/overview/defaultcs.aspx
i.e. no thumbnails just shows an image with the Prev / Next buttons.
What I want to do is on click the image is open the image in a pop up window - I want to use this lightbox control http://lokeshdhakar.com/projects/lightbox2/
How would I attach the mark-up to the displayed image in image gallery.
This is the mark-up required by the control:
<a href="images/ImageTN.jpg" data-lightbox="image-1" alt="Title for image"><img src="images/Image.jpg" alt="Title for image" /></a>
OR can you do what I need to do with your controls.
10 Answers, 1 is accepted
You can attach handler for the client-side onmousedown event of the RadImageGallery wrapping DIV element and if the event target is IMG tag, manually add new item to the RadLightBox control and open it. Here is an example with RadLightBox control and RadImageGallery:
Hope this helps.
Thank you for the quick response.
I'm looking for examples of the ItemDataBound for the Image Gallery control.
I'm thinking of adding that relavent JS in this event.
For this particular scenario and requirement, it will not be possible to achieve the desired behavior by handling the OnItemDataBound event and you should use the suggested approach from my previous post, where the onmousedown event is handled.
However, if you need to attach the same event handler from the code-behind, I would suggest the OnPreRender event, because you need to attach the handler only once and the OnItemDataBound event will fire for each item in the control.
Not sure I can use your first approach, I don't want to add another image to the gallery control, I only wish to attached the code to open the Lightbox.
I will try again with the OnPreRender event.
Please let me know if everything is working correctly with the OnPreRender approach and if you need any further assistance on this matter.
Thank you for the timely response, I'm in the middle fothis now. I still can't find any examples on using the OnPreRender event. And I'm no further forward.
I have tried adding a template, but these don't seem to work as std templates as used in other controls in that they are added as individual items not a pattern for all.
Maybe my problem comes from binding to a folder, should this limit me in anyway?
One last thing the templates link in your answer doesn't work, and I'm looking at this link, is this the correct url?:
Regarding the templates of the RadImageGallery, you are correct that they behavior differently than the other controls and each template will define one item only. With that in mind, if you need to create multiple items with the same template, you need to create a template for every item.
As for the link in my initial post, it is indeed broker and the correct one is the one you have posted:
Finally, for attaching the handler for the onmousedown event on server-side you can use the following:
In your sample , it's simple but don't represent the reality , you insert the data in hard.
If we want to use OnItemDataBound
And get the dataitem, to have a dynamic value from datasource object.
So you don't have think for the reality to use dataitem object like other object like RadGrid , listview or Repeater.
So have you an idea ?
Indeed, with the current implementation of the RadImageGallery it is not possible to retrieve the data item bound to the ImageGalleryItem and the only possible option would be to use the RadImageGallery DataSource object.
If you think that such functionality will be a good addition to the control you could create a public item in our Ideas & Feedback Portal: