This is a migrated thread and some comments may be shown as answers.

Loading images dynamically

2 Answers 265 Views
LightBox
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 11 Jun 2014, 10:55 PM
Do you have an example of how to pass in an argument (for example an image name) from a javascript function to a radlightbox when it opens?  I want to do something like the below, where the onmouseover in the <img src opens the lightbox if I hard code the value in the <asp:Image.
I need to load different images on different img src tags so I thought passing the image name via the funcion was the cleanest way to do so. 

Is this the best way to do this:
http://www.telerik.com/forums/parameterized-lightbox-show()-functions---how-to-do-it

The disadvantage is that it looks like every image is loaded when the page is rendered, I was hoping it load the image dynamically.
Thanks for your help!



<script type="" >
function loadlb(imageName) {
        var rbx = $find('<%= rlbBox.ClientID %>');
        rbx.show();
}
</script>

<telerik:RadLightBox Modal="true" RenderMode="Auto" ClientIDMode="Static" ID="rlbBox" runat="server" ShowCloseButton="true">
        <ClientSettings><AnimationSettings></AnimationSettings></ClientSettings>
        <Items>
            <telerik:RadLightBoxItem>
                <ItemTemplate>
<asp:Image runat="server" ImageUrl="<image_from_loadlb>"/> 
                </ItemTemplate>
            </telerik:RadLightBoxItem>                 
        </Items>
</telerik:RadLightBox>


<img src=<some image> onmouseover="loadlb('imageToLoad'.jpg')" >

2 Answers, 1 is accepted

Sort by
0
Kostadin
Telerik team
answered on 16 Jun 2014, 11:38 AM
Hi Mark,

The approach in the provided forum thread refers only when you are using a template. If you want to display an image you could either load all image in the LightBox control and use the set_currentItemIndex(index) method to point to the image which needs to be shown or load the image dynamically as demonstrated in the following help article.

Regards,
Kostadin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
mack
Top achievements
Rank 1
answered on 27 Jun 2016, 11:37 AM

Hi mark check this useful article.I hope it will solve your problem

https://www.mindstick.com/Articles/478/dynamically-loading-image-in-image-control-in-asp-dot-net

http://sarajchipps.com/post/55986231286/how-to-use-dynamic-images-in-the-aspnet

 

Tags
LightBox
Asked by
Mark
Top achievements
Rank 1
Answers by
Kostadin
Telerik team
mack
Top achievements
Rank 1
Share this question
or