Wednesday, March 21, 2012

Ajax Slideshow from Database

I have a web application with a database that stores, among other things, productname, description, and imagefilename.

i have been beating my head against the wall trying to write javascript or a web service to populate an Ajax slideshow using that data.

Can anyone steer me out of this dead end?

Thanks in advance for any help.

I am currently working on a similiar project. I am not sure if I am doing things 100% correctly, but I basically followed the examples in the Toolkit. I populate the AjaxControlToolkit.Slide objects individually from the filename and then create an array AjaxControlToolkit.Slide[] full of these objects and return it via the GetSlides() web service. Hopefully you will know how to get the data out of your particular database and populate the slide objects.

I personally wrote wrappers SlideShowDocuments for my slide internal data mostly because I needed to keep track of which slide was on the screen at a time, and I didn't want to use a hack with the description fields. Inside the SlideShowDocuments object is where I connect to the Database and create the prepared information for the Slide objects.

I basically used the contextKey to create the SQL to select the appropriate rows. Then I move the information and formatted the filename into my internal structure for a SlideShowDocument object.

You shouldn't HAVE to write any Javascript, the SlideShowExtender does all the work for you! Here is how I went about it... hope this helps!

[System.Web.Services.WebMethod]

[System.Web.Script.Services.ScriptMethod]publicstatic AjaxControlToolkit.Slide[] GetSlides(string contextKey)

{

SlideShowDocuments _slideShowDocuments =newSlideShowDocuments(contextKey);

_slideArray =new AjaxControlToolkit.Slide[_slideShowDocuments.Count];

for (int i = 0; i < _slideShowDocuments.Count; i++)

{

_slideArray[i] =new AjaxControlToolkit.Slide(_slideShowDocuments[i].Filename,"","");

}

return _slideArray;

}


Thank you for your advice. I actually stumbled across another post on the forum that really did the trick for me and may be helpful to you too.

http://forums.asp.net/p/1115257/1728447.aspx#1728447

Thanks for taking time to reply.

Steve

No comments:

Post a Comment