0

私は Web パーツを使用しており、以下のコードを記述します

しかし、それは1つの画像のみを取得します>>>ライブラリからすべての画像を取得し、javascriptまたはjqueryを使用して30秒ごとに画像を変更するにはどうすればよいですか??

public class MSDN : System.Web.UI.WebControls.WebParts.WebPart
    {
        Image myimage = new Image();
        protected override void CreateChildControls()
        {
            myimage.Height = 140;
            myimage.Width =999;
            SPSite mysite = SPContext.Current.Site;
            SPWeb myweb = SPContext.Current.Web;
            SPList mylist = myweb.Lists["Pic Lib"];
            SPQuery myquery = new SPQuery();
            myquery.Query = "<OrderBy><FieldRef Name='FileLeafRef' />"+
                            "<FieldRef Name='Status' /></OrderBy>"+
                            "<Where><Eq><FieldRef Name='Status' />"+
                            "<Value Type='Choice'>Active</Value></Eq></Where>";
            string serverpath = mysite.ServerRelativeUrl.ToString();
            SPListItemCollection mylistitem = mylist.GetItems(myquery);
            if (mylistitem.Count > 0)
            {
                myimage.ImageUrl = serverpath + mylistitem[mylistitem.Count - 1].Url.ToString();
            }
            else
            {
                this.Page.Response.Write("No image found");
            }
            base.CreateChildControls();
        }
        protected override void Render(HtmlTextWriter writer)
        {
            myimage.RenderControl(writer);          
        }
    }
}
4

1 に答える 1

0

SharePoint クライアント オブジェクト モデルのMSDN リンクを使用して、リストを照会し、画像の URL を取得し、それを JavaScript 配列に格納します。次に、任意の jquery プラグイン (SlidesJS など、Google の最初のリンク) を使用するか、独自に記述して画像を反転します。 30秒ごと。

于 2013-04-10T01:43:22.917 に答える