从库中获取图像并在sharepoint中每30秒更改一次图像?

时间:2013-04-01 19:50:35

标签: javascript jquery ajax sharepoint sharepoint-2010

我正在使用网络部分,我在下面编写代码

但它只获取一个图像>>>如何从库中获取所有图像并使用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);          
        }
    }
}

1 个答案:

答案 0 :(得分:0)

您可以使用SharePoint客户端对象模型MSDN link查询列表并获取图片网址,将其存储在javascript数组中 然后使用任何jquery插件(如SlidesJS ..谷歌上的第一个链接)或编写自己的插件每30秒翻转一次图像。