add images to royal slider dynamically c# code behind

artmanturkey's Avatar


20 Mar, 2017 03:45 PM


I bought Royal slider from codecanyon. I don't know JS well. I'm just trying add slides on slider from codebehind c# project. But i can't do it. Because for control slides from code behind i should add runat="server" on main slider div.

<div id="gallery1" runat="server" class="royalSlider rsDefault rsHor rsWithThumbsHor rsContainer">

But when i put "runat" it is displaying only first slide and first thumbnail. How can i add slide from code behind from ".cs" file?

Thanks for help...

  1. Support Staff 1 Posted by Dmitry Semenov on 20 Mar, 2017 04:07 PM

    Dmitry Semenov's Avatar


    Before the initialization you can modify structure in any way, all child elements of .royalSlider elements will be treated as a slide. If you have just one slide - then you have just one child element, check if your backend code generates correct markup.

    After slider initialization, slides can be dynamically added via appendSlide method, more info at

  2. 2 Posted by artmanturkey on 21 Mar, 2017 12:39 AM

    artmanturkey's Avatar


    Thank you for your urgent reply. But i think you didn't understand exactly what i'm trying to do. Your answer is working on javascript. I need to check and add slides on server side codes. Because photos are coming from sql database. On my data table i have 3 photo groups, and every groups has 20 images. I'm checking photos from database if it has data or not. My code example on below;

    ProductID= Request.QueryString["ProductID"].ToString();
    sqlstr = "SELECT * FROM Foto WHERE ProductID=" + ProductID
    SqlDataReader drPhoto = Artman.ArtDataReader(sqlstr);
            if (drPhoto .Read())
                for (int i = 1; i <= 20; i++)
                    PhotoCellName = "G" + i.ToString();
                    PhotoData = drFoto[PhotoCellName].ToString();

                    if (string.IsNullOrEmpty(PhotoData ) == false)
                        ThumbPhotoLink = "/Images/ProductPhotos/" + ProductID + PhotoCellName + "S.jpg";

                        SliderPhotoLink = "/Images/ProductPhotos/" + ProductID + PhotoCellName + "M.jpg";
                        BigPhotoLink = "/Images/ProductPhotos/" + ProductID + PhotoCellName + "B.jpg";
    now i should add this images in slider. from serverside code. not with javascript.

    Thank you,

  3. 3 Posted by artmanturkey on 21 Mar, 2017 01:07 AM

    artmanturkey's Avatar

    Thank you for your interest. I fixed problem.

    Your script is really perfect for use and customization...

    Good job...

  4. artmanturkey closed this discussion on 21 Mar, 2017 01:08 AM.

Comments are currently closed for this discussion. You can start a new one.

Keyboard shortcuts


? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac