InfoPath library throws NotImplementedException for XmlFormView.XmlForm.SaveAs method
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开发者_Go百科 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!!
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.
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.
精彩评论