(I did post this question in the infopath/sharepoint forum, but now realised it's a general infopath newbie and not just sharepoint related, so here it is if someone can give directions for help, thanks.)
I am having an issue with infoPath Forms and C#,
I have a 1st form open to the user, and when he click a button it opens a 2nd form.
Sounds pretty easy, but I have tried many ways and still error.
(environment is InfoPath Forms 2007 in Sharepoint and code: C#)
this is what I have:
- form1 . a text field where I enter the URL of form2
. a button with code below
The issue is that if I type the URL of form2
(http://sharepointserver/sites/MySiteCol/Myinfopath/_layouts/FormServer.aspx?XsnLocation=http://sharepointserver/sites/MySiteCol/FormServerTemplates/form2.xsn&SaveLocation=http://sharepointserver/sites/Myinfopath/InfoPathLib)
in the text field and press the button I get this error
"Critical Error : An error occurred submitting this form to the Web server. The form will now be closed."
But instead of the URL of form2.xsn I type http://www.google.com/ they it works (well except the image somehow, but that's not the problem)
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Web;
// get the text field entry
string out_URL = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:textURLField", NamespaceManager).Value;
// now go to that URL
HttpContext.Current.Response.Redirect(out_URL , false); --> is not working for complex address, but works for simple domain (http://google.com/)
PS: form1 & form2 are both Forms compatible + FullTrust security.
So.. WHAT'S WRONG WITH THIS or WHAT IS THE BETTER WAY TO OPEN A NEW FORM FROM AN INFOPATH FORM ?
(please don't say "Application.XmlForms.NewFromFormTemplate" as it' not compatible with InfoPath forms, only client)
Many many thanks, you would save my day/week/infopath future projects.