Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 1st, 2010, 07:39 PM
Authorized User
Join Date: Apr 2009
Posts: 48
Thanks: 16
Thanked 0 Times in 0 Posts
Default Ajax toolkit SlideShowextender with data from page method

Hi there,
I am trying to make an AjaxToolkit SlideSHow extender work.
The extender sits in a contentpage, with the scriptmanager in the masterpage. The problem seems to be that the private static DataTable declared in the code behind as global, does not keep its data until the page method called by the extender needs it. I put in a gridview just to see if the data comes back from the database, and that works. Also feeding the page method hard coded images works.

The mark up is :

 <asp:Panel ID="Panel1" runat="server">
            <asp:Label ID="lblImgTitle" runat="server"></asp:Label>
            <asp:Image ID="imgShowImage" runat="server" 
                Style="border: 1px solid black;width:auto" 
                AlternateText="" />
            <asp:Label runat="server" ID="lblImage"/><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" />
            <cc1:SlideShowExtender ID="slideshowextend1" runat="server"

and the code behind is like so

public partial class Accomodations_Default2 : System.Web.UI.Page
    private static DataTable photoSlides = new DataTable();

    protected void Page_Load(object sender, EventArgs e)
        if (this.IsPostBack)
            int AccId = Convert.ToInt32(Request.QueryString.Get("Id"));
            //get the slides for the slideshow from the database
            //start with declaring variables and parameters
            DataTable photoSlides;
            SqlDataReader myReader;
            SqlParameter AccIdParam;
            SqlConnection myCon = new SqlConnection();
            //create connection
            myCon.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;

            SqlCommand myCommand = new SqlCommand();
            myCommand.CommandText =
                "SELECT ToolTip, Description, PhotoUrl FROM Photo2 WHERE (ExternalId = @ExtId) AND (PhotoType = 'Accomodation')";
            myCommand.CommandType = CommandType.Text;
            myCommand.Connection = myCon;

            AccIdParam = new SqlParameter();
            AccIdParam = new SqlParameter();
            AccIdParam.ParameterName = "@ExtId";
            AccIdParam.SqlDbType = SqlDbType.Int;
            AccIdParam.Size = 32;
            AccIdParam.Direction = ParameterDirection.Input;
            AccIdParam.Value = AccId;


            myReader = myCommand.ExecuteReader(CommandBehavior.CloseConnection);

            photoSlides = new DataTable();

            // set the initial image
            if (photoSlides.Rows.Count > 0)
                imgShowImage.ImageUrl = photoSlides.Rows[0]["PhotoUrl"].ToString();
            GridView1.DataSource = photoSlides;

    public static AjaxControlToolkit.Slide[] GetSlides()
        //AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[3];

        //slides[0] = new AjaxControlToolkit.Slide("../Images/KANO.JPG", "Ascent", "Cool moon night...");
        //slides[1] = new AjaxControlToolkit.Slide("../Images/KANO2.JPG", "Desert", "Red moon desert...");
        //slides[2] = new AjaxControlToolkit.Slide("../Images/KANO3.JPG", "Tulips", "Beautiful tulips...");

        AjaxControlToolkit.Slide[] slides = new AjaxControlToolkit.Slide[photoSlides.Rows.Count];

        for (int i = 0; i < photoSlides.Rows.Count; i++)
            DataRow dr = photoSlides.Rows[i];
            slides[i] = new AjaxControlToolkit.Slide(
        return slides;
any suggestions?

best regards, Robin

Last edited by robbaralla; March 1st, 2010 at 07:41 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
AJAX Control Toolkit AutoCompleteExtender ilegend .NET Framework 3.5 0 September 24th, 2008 03:50 AM
AJAX Control Toolkit - AlwaysVisibleControl Extend ilegend .NET Framework 3.5 1 September 24th, 2008 02:14 AM
Save new order of Ajax ReorderList toolkit angshujit ASP.NET 2.0 Basics 0 May 30th, 2008 02:10 AM
How to use Ajax ToolKit on Server for ASP.Net2.0 abhi.sharma05 ASP.NET 2.0 Professional 2 June 18th, 2007 12:07 PM
Choose your ajax toolkit hazemtorab BOOK: Professional Ajax ISBN: 978-0-471-77778-6 1 January 1st, 2007 02:47 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.