【问题标题】:InfoPath library throws NotImplementedException for XmlFormView.XmlForm.SaveAs methodInfoPath 库为 XmlFormView.XmlForm.SaveAs 方法引发 NotImplementedException
【发布时间】:2011-05-18 08:09:16
【问题描述】:

我在 SharePoint 页面中使用 XmlFormView 查看启用 InfoPath 浏览器的表单并以编程方式添加一些打开和保存逻辑。

一切正常,没有XmlForm.SaveAs 方法。如果我在实例化的 XmlForm 上调用此方法并使用有效位置,此方法将引发 NotImplementedException,请参见代码:

ASPX:

<InfoPath:XmlFormView ID="infoPathFormView" ShowHeader="false" Style="width: 100%;" runat="server" />

后面的代码:

infoPathFormView.SaveLocation = "http://localhost/MyFormLibrary";
infoPathFormView.DataBind();

if(infoPathFormView.XmlForm.New)
{
   string fileName = Page.User.Identity.Name;
   infoPathFormView.XmlForm.SaveAs(fileName); // This line throws.
}
else
{
   infoPathFormView.XmlForm.Save();
}

导致以下异常和堆栈跟踪:

方法或操作不是 实施的。在 Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost.SaveAs(字符串 文件网址)在 MyProject.ShowInfoPathForm.SaveButton_Click(对象 发件人,EventArgs eventArguments)
在 System.Web.UI.WebControls.LinkBut​​ton.OnClick(EventArgs 吃 System.Web.UI.WebControls.LinkBut​​ton.RaisePostBackEvent(字符串 事件参数)在 System.Web.UI.WebControls.LinkBut​​ton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(字符串 事件参数)在 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler 源控件,字符串 eventArgument)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 后数据)在 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)

为了清楚起见,我发现 Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost 是一个继承自抽象 XmlForm 类的内部类。

  • 有人知道为什么这段代码会抛出 NotImplementedException 吗?
  • 是否有一种解决方法可以使用指定的文件名保存 XmlForm?

提前致谢!!

【问题讨论】:

    标签: c# .net sharepoint infopath xmlformview


    【解决方案1】:

    出于安全原因,XmlFormView 控件的 XsnLocation、XmlLocation 和 SaveLocation 属性必须指定与自定义页面在同一网站集中的位置。

    【讨论】:

      【解决方案2】:

      请注意,SaveAs 不适用于服务器表单,正如您从以下问题链接的文章中指定的那样:“只能通过在 Microsoft Office InfoPath 2007 中打开的表单中运行的代码访问此类型或成员。”

      考虑使用 SaveLocation (http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.savelocation.aspx) 在与模板相同的网站集中指定文件名。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-04-15
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多