SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I followed the Code

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;


for showing the InfoPath form in a webpart. I am a getting valid InfoPath form in the SharePoint webpart.

But when I follow the same code for showing InfoPath form in the Custom Master page application, I could not able to show the InfoPath form. How can I acheive this?

share|improve this question
I have closed your near identical earlier question – SPDoctor Nov 6 '11 at 17:23

By default a masterpage does not allow inline code for security reasons and I personally would not change this behavior for security measures.

Your best bet is to develop either:

  • A custom WebPart and add it to a WebPart page of your choice.
  • A custom layouts ASPX page of your choice with embedded code.
  • A custom WebControl and add it to the masterpage of your choice.
share|improve this answer

You might this solution: In this solution, the InfoPath control is called via an ASP.NET control on the ASPX page instead of the code-behind.

share|improve this answer
I followed this Blog.I am not adding Xmlforview tag (for e.g<Cc1:XmlFormView ID="XmlFormView1" Style="width:100%;" runat="server"/> in Aspx page.But In code behind i have written the Code – user876869 Nov 7 '11 at 15:14
Dynamically In code behind i have written the Code protected void Page_Load(object sender, EventArgs e) { XmlFormView formview = null; formview = new XmlFormView(); formview.Width = Asp.Unit.Percentage(100); formview.Height = Asp.Unit.Pixel(800); formview.XsnLocation = "dev/formlibrary/forms/template.xsn";; formview.ShowHeader = false; formview.ShowFooter = false; formview.Hidden = false; this.Page.Controls.Add(formview); } Can i know where i am doing wrong ? – user876869 Nov 7 '11 at 15:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.