I'm at my wits end with this issue. I am wanting to use a SlideShowExtender from the AjaxControltoolkit for a "CMS-like" website but I am getting the error message... "ajaxcontroltoolkit.slideshowextender object reference not set to an instance of an object. ajaxcontroltoolkit.slideshowextender.oninit(eventargs e)." I am using masterpages and have included a scriptmanagerproxy on the default page and a tookitscriptmanager in the PDAP.master masterpage. Here is the code. It's rough draft and only in concept stage.
PDAP.master
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="PDAP.master.cs" Inherits="PDAP" %> Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<title></title>
<form id="form1" runat="server"> <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="~/Slideshow.asmx" /> </Services> </ajax:ToolkitScriptManager> <asp:ContentPlaceHolder id="HeadContent" runat="server"> PDAP </asp:ContentPlaceHolder> <div> <div id="centercontent" > <asp:ContentPlaceHolder id="CenterContent" runat="server" > CenterContent </asp:ContentPlaceHolder> </div> <div id="rightcontent"> <asp:ContentPlaceHolder ID="RightContent" runat="server"> RightContent </asp:ContentPlaceHolder> </div> <div id="leftcontent"> <asp:ContentPlaceHolder ID="LeftContent" runat="server" > LeftContent </asp:ContentPlaceHolder> </div> </div> </form>
default.aspx <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/PDAP.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="CenterContent">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" ProfileService-Path="~/Slideshow.asmx">
<Services >
<asp:ServiceReference Path="~/Slideshow.asmx" InlineScript="false" />
</Services>
</asp:ScriptManagerProxy>
Default page with Slideshow
<ajax:SlideShowExtender ID="SlideShowExtender1"
runat="server"
Loop="true"
SlideShowAnimationType="SlideRight"
PlayInterval="4000"
SlideShowServiceMethod="GetSlides"
SlideShowServicePath="Slideshow.asmx" >
</ajax:SlideShowExtender>
<asp:Image ID="imgslides"
runat="server" />
</asp:Content>
Web Service - Slideshow.cs
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services;
/// /// Summary description for Slideshow /// [WebService(Namespace ="http://microsoft.com/webservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the >following line. [System.Web.Script.Services.ScriptService] public class Slideshow : System.Web.Services.WebService {
public Slideshow () { //Uncomment the following line if using designed components //InitializeComponent(); } [System.Web.Services.WebMethod] [System.Web.Script.Services.ScriptMethod] public AjaxControlToolkit.Slide[] GetSlides() { string[] imagenames = System.IO.Directory.GetFiles(Server.MapPath("~/Images")); AjaxControlToolkit.Slide[] photos = new AjaxControlToolkit.Slide[imagenames.Length]; for (int i = 0; i < imagenames.Length; i++) { string[] file = imagenames[i].Split('\\'); photos[i] = new AjaxControlToolkit.Slide("Images/" + file[file.Length - 1], file [file.Length - 1], ""); } return photos; }
}
I took an example and was using this to learn by but the code is on a dev server where i don't have access to IIS.
Please take a look and see what I'm doing wrong.