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.
|
<span class="kwrd">using</span> System;<br /><span class="kwrd">using</span> ASP = System.Web.UI.WebControls;<br /><span class="kwrd">using</span> System.Web;<br /><span class="kwrd">using</span> Microsoft.Office.InfoPath.Server.Controls;<br /><br /><br /><span class="kwrd">namespace</span> WMDD.WebParts<br />{<br /> <span class="kwrd">public</span> <span class="kwrd">class</span> FormViewer : ASP.WebParts.WebPart<br /> {<br /> <span class="kwrd">protected</span> <span class="kwrd">override</span> <span class="kwrd">void</span> CreateChildControls()<br /> {<br /> XmlFormView formView;<br /> formView = <span class="kwrd">new</span> XmlFormView();<br /> formView.Width = ASP.Unit.Percentage(100);<br /> formView.Height = ASP.Unit.Pixel(100);<br /> formView.XsnLocation = <span class="str">"Path to form XSN"</span>;<br /> formView.ShowHeader = <span class="kwrd">false</span>;<br /> formView.ShowFooter = <span class="kwrd">false</span>;<br /> <br /> <span class="kwrd">this</span>.Controls.Add(formView);<br /> <span class="kwrd">base</span>.CreateChildControls();<br /> } <br /> }<br />} |