1
votes

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.

3
Just was thinking, could this be that the AjaxControlToolkit.dll may nopt be on the dev server?Matt Pedigo

3 Answers

0
votes

first, I would put a try catch in you code, then put break points at the beginning of each function. Then walk through with f10 and when you get to the point where the code jumps into the catch, then you can identify the troublemaker.

let me know what you find...

0
votes

I had this error and it was because the slideshowextender was not seeing the "TargetControlID" control. In my case I had a spelling mistake. Hope this helps.

0
votes

Had exact same issue, similar scenario, including master page. Couldn't hit any breakpoints as it immediately failed.

Trial and error yielded the answer - needed rest of the properties filled in, and as pintosack mentioned - TargetControlID.

    <asp:Image ID="Image1" runat="server" Height="316px" Width="388px" />
<cc1:SlideShowExtender ID="SlideShowExtender1" runat="server" 
    TargetControlID="Image1" 
    SlideShowServiceMethod="GetSlides" 
    AutoPlay="true" 
    ImageTitleLabelID="imageTitle"
    ImageDescriptionLabelID="imageDescription"
    NextButtonID="btnNext" 
    PlayButtonText="Play" 
    StopButtonText="Stop" 
    PreviousButtonID="prevButton" 
    PlayButtonID="btnPlay" 
    Loop="true" 
    SlideShowAnimationType="FadeInOut">
</cc1:SlideShowExtender> 
<div>
    <asp:Label ID="lblDesc" runat="server" Text=""></asp:Label><br />
    <asp:Button ID="btnPrev" runat="server" Text="Previous" />
    <asp:Button ID="btnPlay" runat="server" Text="" />
    <asp:Button ID="btnNext" runat="server" Text="Next" />
</div>