前台
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Image ID="ImgPhotos" runat="server"
ImageUrl="~/MyBlogs/Photo/0.jpg"
AlternateText="" /> <br />
<asp:Label runat="server" ID="imageDescription">
</asp:Label><br /><br />
<asp:Button runat="Server" ID="prevButton" Text="上一个" />
<asp:Button runat="Server" ID="playButton" Text="开始" />
<asp:Button runat="Server" ID="nextButton" Text="下一个" />
<asp:SlideShowExtender ID="SlideShowExtender1" runat="server" TargetControlID="ImgPhotos"
SlideShowServiceMethod="GetSlides"
AutoPlay="true"
ImageTitleLabelID="imageTitle"
ImageDescriptionLabelID="imageDescription"
NextButtonID="nextButton"
PlayButtonText="开始"
StopButtonText="暂停"
PreviousButtonID="prevButton"
PlayButtonID="playButton"
Loop="true" PlayInterval="1000" > </asp:SlideShowExtender>
后台是在一个repeater控件中点击给SlideShowExtender添加图片的,repeater控件相当于一个相册列表
/// <summary>
/// repeater控件中的操作
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected void rpAlbum_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "show")
{ int id =Convert.ToInt32(e.CommandArgument);
PhotoManager pm = new PhotoManager();
List<Photo> photos = new List<Photo>();
try { photos = pm.AnAlbumOfPhotos(id);
GetSlides(photos);
}
catch (Exception ex) {
ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('"+ex+",请稍后再试!')</script>");
} } }
/// <summary>
///
/// </summary>
/// <param name="photos"></param>
/// <returns></returns>
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public AjaxControlToolkit.Slide[] GetSlides(List<Photo> photos)
{ AjaxControlToolkit.Slide[] act=new AjaxControlToolkit.Slide[photos.Count]; Photo ph;
for(int i=0;i<photos.Count;i++)
{ ph= photos[i];
act[i]=new AjaxControlToolkit.Slide(ph.Path,ph.PName,ph.PDescribe); }
return act;
}
typeof(Sys) === 'undefined' ASP.NET Ajax 客户端框架未能加载。页面貌似有这种问题。但是不知道怎么办
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:Image ID="ImgPhotos" runat="server"
ImageUrl="~/MyBlogs/Photo/0.jpg"
AlternateText="" /> <br />
<asp:Label runat="server" ID="imageDescription">
</asp:Label><br /><br />
<asp:Button runat="Server" ID="prevButton" Text="上一个" />
<asp:Button runat="Server" ID="playButton" Text="开始" />
<asp:Button runat="Server" ID="nextButton" Text="下一个" />
<asp:SlideShowExtender ID="SlideShowExtender1" runat="server" TargetControlID="ImgPhotos"
SlideShowServiceMethod="GetSlides"
AutoPlay="true"
ImageTitleLabelID="imageTitle"
ImageDescriptionLabelID="imageDescription"
NextButtonID="nextButton"
PlayButtonText="开始"
StopButtonText="暂停"
PreviousButtonID="prevButton"
PlayButtonID="playButton"
Loop="true" PlayInterval="1000" > </asp:SlideShowExtender>
后台是在一个repeater控件中点击给SlideShowExtender添加图片的,repeater控件相当于一个相册列表
/// <summary>
/// repeater控件中的操作
/// </summary>
/// <param name="source"></param>
/// <param name="e"></param>
protected void rpAlbum_ItemCommand(object source, RepeaterCommandEventArgs e) { if (e.CommandName == "show")
{ int id =Convert.ToInt32(e.CommandArgument);
PhotoManager pm = new PhotoManager();
List<Photo> photos = new List<Photo>();
try { photos = pm.AnAlbumOfPhotos(id);
GetSlides(photos);
}
catch (Exception ex) {
ClientScript.RegisterStartupScript(this.GetType(), "msg", "<script>alert('"+ex+",请稍后再试!')</script>");
} } }
/// <summary>
///
/// </summary>
/// <param name="photos"></param>
/// <returns></returns>
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public AjaxControlToolkit.Slide[] GetSlides(List<Photo> photos)
{ AjaxControlToolkit.Slide[] act=new AjaxControlToolkit.Slide[photos.Count]; Photo ph;
for(int i=0;i<photos.Count;i++)
{ ph= photos[i];
act[i]=new AjaxControlToolkit.Slide(ph.Path,ph.PName,ph.PDescribe); }
return act;
}
typeof(Sys) === 'undefined' ASP.NET Ajax 客户端框架未能加载。页面貌似有这种问题。但是不知道怎么办