Embed InfoPath form in SharePoint page as Web Part
9. May 2007 03:48

You can use the XMLFormView class to render an InfoPath (.xsn) form to a page.

Here's a simple example of making a Web Part to display a form using the FormView class.

 

using System;
using ASP = System.Web.UI.WebControls;
using System.Web;
using Microsoft.Office.InfoPath.Server.Controls;


namespace WMDD.WebParts
{
public class FormViewer : ASP.WebParts.WebPart
{
protected override void CreateChildControls()
{
XmlFormView formView;
formView = new XmlFormView();
formView.Width = ASP.Unit.Percentage(100);
formView.Height = ASP.Unit.Pixel(100);
formView.XsnLocation = "Path to form XSN";
formView.ShowHeader = false;
formView.ShowFooter = false;

this.Controls.Add(formView);
base.CreateChildControls();
}
}
}
Exception: Object reference not set to an instance of an object.
Tags: Comments (6) | Permalink

Comments

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading