【发布时间】:2013-10-22 07:25:54
【问题描述】:
我对这个问题束手无策。我想将 AjaxControltoolkit 中的 SlideShowExtender 用于“类似 CMS”的网站,但我收到错误消息... “ajaxcontroltoolkit.slideshowextender 对象引用未设置为对象的实例。ajaxcontroltoolkit.slideshowextender.oninit(eventargs e)。”我正在使用母版页,并在默认页面上包含了一个 scriptmanagerproxy,在 PDAP.master 母版页中包含了一个 takeitscriptmanager。这是代码。这是草稿,仅处于概念阶段。
PDAP.master
过渡//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
<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(命名空间="http://microsoft.com/webservices/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // 要允许使用 ASP.NET AJAX 从脚本调用此 Web 服务,请取消注释 > 下一行。 [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 的开发服务器上。
请看看我做错了什么。
【问题讨论】:
-
只是在想,难道 AjaxControlToolkit.dll 可能不在开发服务器上吗?
标签: c# asp.net asp.net-ajax ajaxcontroltoolkit nullreferenceexception