【问题标题】:Sharepoint Insert a new Item using Lists Web ServiceSharepoint 使用 Lists Web 服务插入新项目
【发布时间】:2012-02-20 11:08:24
【问题描述】:

我正在使用 sharepoint 2007。

我有一个名为“用户票证”的列表,其中有一列名为“内容”

我的问题是我正在尝试插入以下文本:

<script type=\"text/javascript\"> </script>

为了避免异常我使用了'HtmlEncode'

但是,sharepoint 忽略了这一点,只是在“内容”列中插入一个空白值。

我的代码:

ListsSoapClient _proxy = new ListsSoapClient();

string ContentValue = 
HttpContext.Current.Server.HtmlEncode("<script type=\"text/javascript\"> </script>");

XmlDocument doc = new XmlDocument();

XmlElement batchElement = doc.CreateElement("Batch");

batchElement.InnerXml = "<Method ID=\"1\" Cmd=\"New\"> <Field Name=\"Ticket_x0020_Details\">ContentValue </Field></Method>";

_proxy.UpdateListItems("User Tickets", UtilHelper.GetXElement(batchElement));

我怎样才能让共享点接受这个值:<script type=\"text/javascript\"> </script>

【问题讨论】:

    标签: web-services sharepoint list sharepoint-2007


    【解决方案1】:

    SharePoint 具有某种用户内容过滤功能。这取决于您要插入的列。它的类型是什么?如果是富文本,SharePoint 将不允许插入脚本内容。

    Upd:过滤掉脚本的想法很自然。想象一下,如果允许,当您打开“AllItems.aspx”视图并执行所有脚本时会发生什么。

    您可以做的是,您可以对内容进行双重编码,以便源代码中的<script> 在您的ContentValue 字段中变为<script>。这样,您的脚本将作为文本保存到列表项中。要将其作为脚本执行,您必须始终调用 HtmlDecode

    【讨论】:

      猜你喜欢
      • 2010-09-10
      • 1970-01-01
      • 1970-01-01
      • 2012-02-22
      • 2012-02-07
      • 1970-01-01
      • 2016-09-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多