Apr 212010

Infopath form server - passing url parameter to a infopath form


I wanted to load a new infopath form into a Xmlformview webpart in Sharepoint, but at the same time pass a url queryparameter to the infopath form.
At first you might think that this can't be done without code behind on the infopath form but I found an easy way to do this based on an article (Steven Van De Craen) of a collegue of mine.
The methods are quit simple

  1. Make sure u get a url parameter in the publishing page by clicking a link (ex http://moss/pages/createdoc.aspx?parameter=23
  2. Create a new custom SharePoint webpart that extends the Microsoft.Office.InfoPath.Server.Controls.XmlFormView class.
  3. Add an eventhandler in the onInit of the webpart for this.initialise
  4. In the handler add code to change the XML nodes in the infopath doc (pass parameter to a hidden field or something).

public class XmlFormViewExtender : Microsoft.Office.InfoPath.Server.Controls.XmlFormView
private bool _error = false;
private string _xpath = null;
private string _param = null;
[System.ComponentModel.Category("My Property Group")]
[WebDescription("parameter Property")]
public string Param
if (_param == null)
{_param = "par";
return _param;
set { _param = value; }
[System.ComponentModel.Category("My Property Group")]
[WebDescription("XPath Property")]
public string XPath
if (_xpath == null)
_xpath = "/my:form/my:param";
return _xpath;
set { _xpath = value; }
protected override void OnInit(EventArgs e)
this.Initialize += new EventHandler(XmlFormViewExtender_Initialize);
protected void XmlFormViewExtender_Initialize(object sender, Microsoft.Office.InfoPath.Server.Controls.InitializeEventArgs e)
if (XmlForm != null)
string value = this.Page.Request.QueryString[Param];
XPathNavigator _xNavMain = this.XmlForm.MainDataSource.CreateNavigator();
XPathNavigator result = _xNavMain.SelectSingleNode(XPath, this.XmlForm.NamespaceManager);
I've also created 2 properties (Param, XPath) for the webpart that hold the name of the parameter it should get (querystring) and the Xpath where to place the value of this param.
So the result of this webpart is that the value of the url parameter par will be filled into the XML of the infopath form in "/my:form/my:param" and will show this data when rendering the form.


Hope this helps someone out!

Published: 4/21/2010  3:20 PM | 0  Comments | 0  Links to this post

Apr 062010

MOSS 2007 anonymous access + forms based authentication

We've also had some problems after this because when we went into a list / library we still got our login page while we had followed all the steps mentioned in the article.

Turns out the problem was that our site was based on a publishing site template.
The solution is to deactivate a feature for the site and turn anonymous authentication off and on again as mentioned in this kb : http://support.microsoft.com/kb/927082/en-us?spid=11373&sid=200


  • Click Start, click Run, type cmd in the Open box, and then click OK.
  • Type the following lines at the command prompt. Press ENTER after each line.
    cd /d %commonprogramfiles%\Microsoft Shared\Web Server Extensions\12\Bin
    stsadm -o deactivatefeature -url http://ServerName -filename ViewFormPagesLockDown\feature.xml
  • Type exit to exit the command prompt.


Note After you run this command-line tool against your site, you must toggle the Site Settings advanced permissions to turn off Anonymous access. Then, turn on Anonymous access again. You must do this for the command to take effect on content that exists in the site.


After this we could open the list with our anonymous user but when we tried creating a new list item (by clicking the new button we saw after setting the anonymous access permissions add for the list) we got the login screen again.


Solution: Check if your list doesn't have a lookup column to another list that does not have anonymous authentication turned on. If so grant anonymous "view" access on the lookup list.

Hope this helps you out!

Published: 4/6/2010  3:19 PM | 0  Comments | 0  Links to this post