2013-04-01 49 views
0

我正在使用的Web部分,我写下面的代码从库中获取图像并在sharepoint中每30秒更改一次图像?

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

回答

0

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

相关问题