InfoPath 库针对 XmlFormView.XmlForm.SaveAs 方法引发 NotImplementedException
我在 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 事件参数)
在 System.Web.UI.WebControls.LinkButton.OnClick(EventArgs 吃 System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(字符串 事件参数) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String 事件参数) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler) 源控件,字符串事件参数)
在 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection 发布数据)于 System.Web.UI.Page.ProcessRequestMain(布尔值 includeStagesBeforeAsyncPoint,布尔值 includeStagesAfterAsyncPoint)
为了清楚起见,我发现 Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost 是一个继承自抽象 XmlForm 类。
- 有谁知道为什么这段代码抛出 NotImplementedException 吗?
- 是否有解决方法能够使用指定的文件名保存 XmlForm?
提前致谢!!
I'm using the XmlFormView in a SharePoint page to view InfoPath browser enabled forms and programmatically add some opening and saving logic.
All goes fine, without the XmlForm.SaveAs method. This method throws an NotImplementedException if I call it on an instantiated XmlForm and with a valid location, see code:
ASPX:
<InfoPath:XmlFormView ID="infoPathFormView" ShowHeader="false" Style="width: 100%;" runat="server" />
Code behind:
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();
}
Resulting in the following exception and stacktrace:
The method or operation is not
implemented. at
Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost.SaveAs(String
fileUrl) at
MyProject.ShowInfoPathForm.SaveButton_Click(Object
sender, EventArgs eventArguments)
at
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs
e) at
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String
eventArgument) at
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String
eventArgument) at
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData) at
System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean
includeStagesAfterAsyncPoint)
For clarity, I found that Microsoft.Office.InfoPath.Server.DocumentLifetime.XmlFormHost is an internal class that inherits from the abstract XmlForm class.
- Does anyone have an idea why this piece of code is throwing a NotImplementedException?
- Is there a workaround to be able to save the XmlForm with the specified filename?
Thanks in advance!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
出于安全原因,XmlFormView 控件的 XsnLocation、XmlLocation 和 SaveLocation 属性必须指定与自定义页面位于同一网站集中的位置。
For security reasons, the XsnLocation, XmlLocation, and SaveLocation properties of the XmlFormView control must specify locations in the same site collection as the custom page.
请注意,另存为不适用于您从问题链接的文章中指定的服务器表单:“只能从在 Microsoft Office InfoPath 2007 中打开的表单中运行的代码访问此类型或成员。”
考虑使用 SaveLocation (http:// /msdn.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.savelocation.aspx) 以在与模板相同的网站集中指定文件名。
Note that the SaveAs is not available for server forms as specified in the article you linked from the question: "This type or member can be accessed only from code running in forms opened in Microsoft Office InfoPath 2007."
Consider using SaveLocation ( http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.savelocation.aspx) to specify file name in the same site collection as the template.