我对这个问题束手无策。我想将 AjaxControltoolkit 中的 SlideShowExtender 用于“类 CMS”网站,但我收到错误消息...“ajaxcontroltoolkit.slideshowextender 对象引用未设置为对象实例。ajaxcontroltoolkit.slideshowextender.oninit(eventargs e)。” 我正在使用母版页,并且在默认页面上包含了一个 scriptmanagerproxy,在 PDAP.master 母版页中包含了一个 takeitscriptmanager。这是代码。这是草稿,仅处于概念阶段。
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>
网络服务 - Slideshow.cs
使用系统;使用 System.Collections.Generic;使用 System.Linq;使用 System.Web;使用 System.Web.Services;
/// /// 幻灯片的摘要描述 /// [WebService(Namespace ="http://microsoft.com/webservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // 允许此 Web 服务从脚本调用,使用 ASP.NET AJAX,取消注释 >following 行。[System.Web.Script.Services.ScriptService] 公共类幻灯片: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; }
}
我举了一个例子,并使用它来学习,但代码位于我无法访问 IIS 的开发服务器上。
请看一下,看看我做错了什么。