App_Code/AjaxService.cs

(完整代码) 1KB

using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;

///引入新的名字空间
using System.Data;
using System.Web.Script.Services;
using AjaxControlToolkit;
using ASPNETAJAXWeb.AjaxAlbum;



/// <summary>
/// AjaxService 的摘要说明
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
///添加脚本服务
[System.Web.Script.Services.ScriptService()]
public class AjaxService : System.Web.Services.WebService
{
    public AjaxService ()
	{
        
    }

	[System.Web.Services.WebMethod()]
	[System.Web.Script.Services.ScriptMethod()]
	public AjaxControlToolkit.Slide[] GetPhotoes(string contextKey)
	{   ///检测参数是否为空
		if(string.IsNullOrEmpty(contextKey) == true) return null;
		///获取参数的值,并转换为分类的ID值
		int categoryID = -1;
		if(Int32.TryParse(contextKey,out categoryID) == false)
		{
			return null;
		}
		///根据分类ID获取其图片
		Album album = new Album();
		DataSet ds = album.GetPhotoByCategory(categoryID);
		if(ds == null || ds.Tables.Count <= 0 || ds.Tables[0].Rows.Count <= 0) return null;
		///创建被播放图片的数组
		Slide[] photoes = new Slide[ds.Tables[0].Rows.Count];
		for(int i = 0; i < ds.Tables[0].Rows.Count; i++)
		{   ///创建一张图片的数组
			Slide photo = new Slide();
			photo.Name = photo.Description = ds.Tables[0].Rows[i]["Title"].ToString();
			photo.ImagePath = ds.Tables[0].Rows[i]["Url"].ToString();
			photoes[i] = photo;
		}
		return photoes;
	}
}

24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明

AI 解读 AI

登录后可用,每次 10 算力,解读结果公开显示在下面。

还没有人解读过这个文件。