How to itereate through repeater control itemtemplate data using Javascript?

Posted on 2007-11-18
Medium Priority
Last Modified: 2013-11-07
Using asp.net 2 (VB).  
I have two controls in place.
1.  An ASP.NET repeater conrol with a string (image path) as part of the Item Template (first element of each row).
2.  A client side javascript image carousel control which requires that string for population. The client side caradd function is already written.

This seems like a simple thing but....  I'd like to either:
1.   Call the carradd javascript upon every itemTemplate itemcreated
2.  Iterate through the completed repeater control, extract the needed string and feed it to the client side function.

I understand that this should probably be done with AJAX but I'm not quite ready to tackle that this week so....

Thank you.
Question by:RichardKline
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 63

Assisted Solution

Zvonko earned 400 total points
ID: 20309538
Show that JavaScript function. It surely needs changes to get the images as parameters from every image in rows. Also state what that function should do on multiple images, change them all at let say one second interval? Chnage randomly one of many images at interval?
LVL 16

Accepted Solution

McExp earned 1600 total points
ID: 20309662
I know you didn't want to involve AJAX in your solution. However, and I make no apologies for this, I would really recomend looking at AJAX, specifically the SlideShowExtender Control in the ASP.NET AJAX Control Toolkit (http://asp.net/AJAX/AjaxControlToolkit/Samples/SlideShow/SlideShow.aspx). It really is simple!

-- WebService method to provide the list to loop --
    <script runat="Server" type="text/C#">
        public static AjaxControlToolkit.Slide[] GetSlides()
            return new AjaxControlToolkit.Slide[] {
            new AjaxControlToolkit.Slide("images/Blue hills.jpg", "Blue Hills", "Go Blue"),
            new AjaxControlToolkit.Slide("images/Sunset.jpg", "Sunset", "Setting sun"),
            new AjaxControlToolkit.Slide("images/Winter.jpg", "Winter", "Wintery..."),
            new AjaxControlToolkit.Slide("images/Water lilies.jpg", "Water lillies", "Lillies in the water"),
            new AjaxControlToolkit.Slide("images/VerticalPicture.jpg", "Sedona", "Portrait style picture")};

-- Items to be in body of page --
        <asp:ScriptManager ID="ScriptManager1" runat="server" />
        <div style="text-align:center">
            <asp:Image ID="Image1" runat="server"
                Style="border: 1px solid black;width:auto"
                ImageUrl="~/SlideShow/images/Blue hills.jpg"
                AlternateText="Blue Hills image" />
            <asp:Label runat="Server" ID="imageLabel1"/><br /><br />
            <asp:Button runat="Server" ID="prevButton" Text="Prev" Font-Size="Larger" />
            <asp:Button runat="Server" ID="playButton" Text="Play" Font-Size="Larger" />
            <asp:Button runat="Server" ID="nextButton" Text="Next" Font-Size="Larger" />
            <ajaxToolkit:SlideShowExtender ID="slideshowextend1" runat="server"
                Loop="true" />

Hopefully you can see from the code above that it's really not that complicated. I can assure you it will take less time to understand and impliment this that it will to engineer a solution the hard way.

Author Comment

ID: 20309841
I give -- AJAX it is.  Perhaps I'll get out that book I purchased.
The extender which McExp references will get me past my immediate hurdle.  
Ultimately, I plan to use Bill Scott's carousel (http://billwscott.com/carousel/ ) which does some really cool things over and beyond the extender.   He also provides an AJAX data source example using PHP (which I want to get involved with right now even less than AJAX).

Thanks to Zvonko for his input.   I'm not sure that his immediate concern is correct (though it certainly may!) but his question made me re-examine my initial beliefs -- kludging an interface might not be as easy as I first thought.

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question