繁体   English   中英

使用CSOM从SharePoint通用列表中获取图像URL

[英]get image url from SharePoint genericlist with CSOM

我正在尝试从列表中获取图像URL,但现在不知道如何。 谷歌上的常规搜索没有帮助。 到目前为止,这是我的代码:

         using(var context = MySession.Current.spcontext.CreateAppOnlyClientContextForSPHost())
        {
            List<Produkt> produkter = new List<Produkt>();
            ListItemCollection listFromSharePoint = _foodRepo.RetriveList(context, PRODUKTER);
            foreach(ListItem items in listFromSharePoint)
            {
                Produkt oneItem = new Produkt();

                oneItem.bild = (string)items["Bild"];  <--Column name is "Bild" but how to get the url?
                produkter.Add(oneItem);
            }
            ViewBag.Produkter = produkter;
        }

我想要的图像:

在此处输入图片说明

一切都从sharepoint加载,但是不知道如何到达url。 有任何想法吗?

访问itemvalues时,它们始终是一个必须强制转换为正确类的对象:

using (ClientContext ctx = new ClientContext(url))
{
    Web web = ctx.Web;
    List list = web.Lists.GetById(listId);
    ListItem item = list.GetItemById(itemId);
    ctx.Load(item);
    ctx.ExecuteQuery();
    FieldUrlValue fieldValue = (FieldUrlValue)item["Bild"]; //<-- casting!
    string bildUrl = fieldValue.Url; //<-- here you can access the values
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM