Loading images dynamically

3 posts, 0 answers
  1. Mark
    Mark avatar
    2 posts
    Member since:
    Jun 2014

    Posted 11 Jun 2014 Link to this post

    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. Kostadin
    Admin
    Kostadin avatar
    1708 posts

    Posted 16 Jun 2014 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. mack
    mack avatar
    1 posts
    Member since:
    Jun 2016

    Posted 27 Jun Link to this post

    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

     

Back to Top