gpt4 book ai didi

c# - Ajax 幻灯片放映扩展程序不起作用

转载 作者:行者123 更新时间:2023-11-30 22:18:24 24 4
gpt4 key购买 nike

我遵循了此链接 Ajax Slide show extender 中的教程

我的代码如下

<div>
<table style="border:Solid 3px #D55500; width:400px; height:400px" cellpadding="0"
cellspacing="0">
<tr style="background-color:#D55500">
<td style=" height:10%; color:White; font-weight:bold; font-size:larger"
align="center">
<asp:Label ID="lblTitle" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
<asp:Image ID="imgslides" runat="server" Height="400px" Width="400px" />
</td>
</tr>
<tr>
<td align="center">
<asp:Label ID="lblimgdesc" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="btnPrevious" runat="server" Text="Prev" CssClass="button" />
<asp:Button ID="btnPlay" runat="server" Text="Play" CssClass="button" />
<asp:Button ID="btnNext" runat="server" Text="Next" CssClass="button" />
</td>
</tr>
</table>
<ajax:SlideShowExtender runat="server" AutoPlay="true" ImageTitleLabelID="lblTitle"
ImageDescriptionLabelID="lblimgdesc" Loop="true"
NextButtonID="btnNext" PreviousButtonID="btnPrevious" PlayButtonID="btnPlay"
PlayButtonText="Play" StopButtonText="Stop"
TargetControlID="imgslides" SlideShowServicePath="Slideshow.asmx"
SlideShowServiceMethod="GetSlides"></ajax:SlideShowExtender>

在我的网络服务中我有一个文件

[WebMethod]     
public AjaxControlToolkit.Slide[] GetSlides()
{
string[] ImageNames = System.IO.Directory.GetFiles(Server.MapPath(@"C:\Users\Mayer\Documents\Visual Studio 2010\Projects\Project1\Project1\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;
}

我有图片文件夹,但看不到我的幻灯片

请帮忙

最佳答案

您应该将相对地址传递给Server.MapPath

它应该是这样的:~\Project1\Project1\Images\ 而不是物理路径:
C:\Users\Mayer\Documents\Visual Studio 2010\Projects\Project1\Project1\Images\

The MapPath method maps the specified relative or virtual path to the corresponding physical directory on the server.

来自文档: http://msdn.microsoft.com/en-us/library/ms524632(v=vs.90).aspx

关于c# - Ajax 幻灯片放映扩展程序不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16105570/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com