使用 CSOM 从 SharePoint genericlist 获取图像 url
get image url from SharePoint genericlist with CSOM
我正在尝试从列表中获取图像 url,但不知道如何获取。 google 上的常规搜索没有帮助。到目前为止,这是我的代码:
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;
}
我想要的图片:
一切都从共享点加载,但不知道如何到达 url。有什么想法吗?
访问项目值时,它们始终是必须转换为正确的对象 class:
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
}
我正在尝试从列表中获取图像 url,但不知道如何获取。 google 上的常规搜索没有帮助。到目前为止,这是我的代码:
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;
}
我想要的图片:
一切都从共享点加载,但不知道如何到达 url。有什么想法吗?
访问项目值时,它们始终是必须转换为正确的对象 class:
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
}