SharePoint创建列表并使用程序管理列表

        列表是SharePoint开发者输入数据的方式之中的一个。使用Web界面创建一个列表并加入一些数据。过程例如以下:
1. 打开站点。

2. 点击全部站点内容。

3. 点击创建。

4. 选择自己定义列表,命名Customers,并输入描写叙述。

选中在高速启动导航显示,点击创建。

        这将创建一个自己定义列表。接下来我们加入三个栏:Region/Size/Sales。

1. 点击功能区创建栏button,命名Region,选择“选项”类型。

添加四个选项:East/West/North/South。其余默认。点击确定。

2. 添加Size栏,相同“选项”类型:Small/Medium/Enterprise,点击确定。
3. 添加Sales栏。选择单行文本,点击确定。
4. 最后,点击功能区列表设置,点击Title链接,将默认的Title改为Name,点击确定。
5. 虽然你更改了Title为Name,在编程时。你仍须要使用Title。将鼠标放在Name字段上,看一下URL的Field=Title。
6. 为了加入一些项目到列表。点击Customers列表,点击加入新项目。完毕例如以下结果。
        你能够对SharePoint 2010 中的列表编敲代码,使你能够管理/创建/读取/更新/删除(CRUD)操作。
1. 管理员身份打开VS 2010.新建项目WPF应用程序。

2. 命名WPFSPListAPP。点击确定。右击MainWindow.xaml文件,选择视图设计器。

3. 加入5个标签/4个文本框/3个button。
        以下是一些Name属性
5. 右击MainWindwow.xaml,查看代码。
6. 右击引用,点击加入服务引用。点击高级。点击加入Web引用
7. 在加入Web引用对话框中,点击本地计算机的Web服务链接。

8. 选择Lists服务形如http://<server name>/_vti_bin/Lists.asmx的Web服务。

你须要更改为自己的服务器名。

提供一个名称。点击加入引用。

9. 这时你能够为每一个button加入事件处理器。Updatebutton负责Web服务连接到SharePoint。你也须要一系列类层次的变量获得用户输入并传递给Lists Web service。当你调用 Lists Web service时,你也须要创建XML将数据从WPF传递到SharePoint列表。XML被称为Collaborative Application Markup Language(CAML)。
        你须要更新MainWindow.xaml的代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using System.Xml.Linq; namespace WPFSPListAPP
{
///
/// MainWindow.xaml 的交互逻辑
///
public partial class MainWindow : Window
{
string strCompanyName = "";
string strRegion = "";
string strSize = "";
string strSales = "";
string strListID = "";
string strViewID = ""; public MainWindow()
{
InitializeComponent();
} private void btnUpdate_Click(object sender, RoutedEventArgs e)
{
strCompanyName = txtbxCompanyName.Text;
strRegion = txtbxRegion.Text;
strSize = txtbxSize.Text;
strSales = "$" + txtbxSales.Text; WPFSPListAPP.MySPWebService.Lists myListService =
new MySPWebService.Lists();
myListService.Credentials = System.Net.CredentialCache.DefaultCredentials;
myListService.Url = "http://smallville-pc/_vti_bin/Lists.asmx"; XmlNode myListView = myListService.GetListAndView("Customers", ""); strListID = myListView.ChildNodes[0].Attributes["Name"].Value;
strViewID = myListView.ChildNodes[1].Attributes["Name"].Value; XmlDocument myListDoc = new XmlDocument();
XmlElement batchXML = myListDoc.CreateElement("Batch"); batchXML.InnerXml="" +
strCompanyName + "" + strRegion +
"" + strSize +
"" + strSales +
"" + ""; XmlNode myListReturn = myListService.UpdateListItems(strListID, batchXML);
MessageBox.Show("SharePoint List was updated!");
} private void btnClear_Click(object sender, RoutedEventArgs e)
{
txtbxCompanyName.Text = "";
txtbxRegion.Text = "";
txtbxSales.Text = "";
txtbxSize.Text = "";
} private void btnExit_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}

10. F5调试。

点击更新。

11. 查看列表。

原理

        本例中你使用了Lists Web service,它提供了很多方式与列表交流----比如加入/删除列表/加入附件/获取列表等。本例中你使用了GetListAndView方法。这次调用。你传递列表名Customers,将返回值映射为XMLNode对象。
XmlNode myListView = myListService.GetListAndView(“Customers”, ““);
        本例也使用了CAML插入数据到SharePoint列表。不得不说CAML冗长而啰嗦。
        最后关键的UpdateListItems方法。传入列表ID和列表架构。
XmlNode myListReturn = myListService.UpdateListItems(strListID, batchXML);
        这种方法使用了native Web services。有优缺点。长处包含易于使用且研究了现有的service,否则你须要自己创建;缺点包含潜在的服务集成性能和CAML语法的冗长复杂性。

SharePoint 创建列表并使用Windows Presentation Foundation应用程序管理列表的更多相关文章

  1. Windows Presentation Foundation (WPF)中的命令(Commands)简述

    原文:Windows Presentation Foundation (WPF)中的命令(Commands)简述 ------------------------------------------- ...

  2. Windows Presentation Foundation(WPF)中的数据绑定(使用XmlDataProvider作控件绑定)

    原文:Windows Presentation Foundation(WPF)中的数据绑定(使用XmlDataProvider作控件绑定) ------------------------------ ...

  3. Windows Presentation Foundation (WPF) 项目中不支持xxx的解决

    一般Windows Presentation Foundation (WPF) 项目中不支持xxx都是由于没引用相应的程序集导致,比如Windows Presentation Foundation ( ...

  4. 【翻译习作】 Windows Workflow Foundation程序开发-第一章02

    1.2      Windows Workflow概览 微软的Windows Workflow Foundation(简称WF)是.NET框架3.0版的一部分..NET3.0其它主要部分是Window ...

  5. 【翻译习作】 Windows Workflow Foundation程序开发-第一章03

    1.2.2.Visual Studio 2005扩展包 微软也为Windows Workflow开发者提供了Visual Studio 2005扩展包.扩展包将许多功能集成到Visual Studio ...

  6. Windows Phone 8初学者开发—第3部分:编写第一个Windows Phone 8应用程序

    原文 Windows Phone 8初学者开发—第3部分:编写第一个Windows Phone 8应用程序 原文地址: http://channel9.msdn.com/Series/Windows- ...

  7. 【翻译习作】 Windows Workflow Foundation程序开发-第一章05

    1.3      开发我们的第一个工作流 也许你曾经在这样的产品经理手下搞过开发:他总是在你身边转悠,并不时的问一句“你还没做完吗?”.在这一部分,我们将用一个简单的Windows Workflow程 ...

  8. 使用WIF实现单点登录Part I——Windows Identity Foundation介绍及环境搭建

    首先先说一下什么是WIF(Windows Identity Foundation).由于各种历史原因,身份验证和标识的管理一般都比较无规律可循.在软件里加入“身份验证”功能意味着要在你的代码里混进处理 ...

  9. 使用WIF实现单点登录Part I——Windows Identity Foundation介绍及环境搭建 -摘自网络

    上个月有一个星期的时间都在研究asp.net mvc统一身份验证及单点登录的实现.经过了一番的探索,最终决定使用微软的Windows Identity Foundation.但是这东西用的人貌似不多, ...

随机推荐

  1. Shell 实现找出两个目录下的同名文件方法

    # 首先我们来创建一些 2 个目录,里面的目录结构及相关文件如下所示: # 从上面的测试目录可以看到, lol.txt lol2.txt 两个文件是两个目录下的同名文件 # 有实际例子,思路就容易出来 ...

  2. SpringBoot 通用返回类设计

    在项目中通常需要为前端设计通过的返回类,返回的格式为: { "status": "success", "data": {...} } 定义通 ...

  3. orecle 函数

    --创建函数语法 create [or replace] function [schema.]function_name (函数参数列表) --参数有IN.OUT.IN OUT三种类型:IN代表需要输 ...

  4. Listview_简单使用_(Virtual)

    1.代码来自于“C:\Program Files (x86)\Borland\Delphi7\Demos\Virtual Listview” 1.1.是使用 ListView来显示数据 1.2.自己管 ...

  5. JNIjw04

    1.VC6(CPP)的DLL代码: #include<stdio.h> #include "jniZ_JNIjw04.h" #include <string> ...

  6. java-登陆界面

    <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...

  7. mongodb之一些简单的增删改查语句

    数据库操作:show dbs;#查看数据库use test;#如果没有就创建一个db;#查看当前数据库db.dropDatabase();#删除数据库 数据操作:show collections:#查 ...

  8. JS前端重点 -- Generator 函数的含义与用法

    Generator 函数的含义与用法 1.generator http://www.ruanyifeng.com/blog/2015/04/generator.html http://it.taocm ...

  9. html5新增语义化标签

    注意:body.section.nav 需要h1-h6. div.header则不需要. 1):<article> 显示一个独立的文章内容. 例如一篇完整的论坛帖子,一则网站新闻,一篇博客 ...

  10. 【2018年全国多校算法寒假训练营练习比赛(第五场)-E】情人节的电灯泡(二维树状数组单点更新+区间查询)

    试题链接:https://www.nowcoder.com/acm/contest/77/E 题目描述 情人节到了,小芳和小明手牵手,打算过一个完美的情人节,但是小刚偏偏也来了,当了一个明晃晃的电灯泡 ...