can u help me
i want to create infopath form from asp.net appliction dynamically so there is no template for this form so how can i create form and template in run time?
i used this code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string requestType = "Request for dynamic request forms";
string requestTitle = "My dynamically created request";
string estimatedCost = "123";
string user = "ASDx";
string costCenter = "999888777"; // TODO: get cost center from UserProfile
int classification = 54321;
string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<?mso-infoPathSolution solutionVersion=\"1.0.0.8\" productVersion=\"12.0.0\" " +
"PIVersion=\"1.0.0.0\" href=\"" +
"http://demo1:1000/PressReleases/Request%20forms/Forms/template.xsn\" " +
"name=\"urn:schemas-microsoft-com:office:infopath:" +
"Request-forms:-myXSD-2007-11-07T19-32-12\" ?>" +
"<?mso-application progid=\"InfoPath.Document\" " +
"versionProgid=\"InfoPath.Document.2\"?>" +
"<my:myFields xmlns:my=\"" +
"http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-11-07T19:32:12\" " +
"xml:lang=\"en-us\">" +
// Here I fill the fields:
"<my:RequestType>" + requestType + "</my:RequestType>" +
"<my:RequestTitle>" + requestTitle + "</my:RequestTitle>" +
"<my:EstimatedCost>" + estimatedCost + "</my:EstimatedCost>" +
"<my:User>" + "ASD" + "</my:User>" +
"<my:CostCenter>" + costCenter + "</my:CostCenter>" +
"<my:Classification xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
classification + "</my:Classification>" +
"</my:myFields>";
this.Page.Response.Clear();
this.Page.Response.AppendHeader("Content-Disposition", "attachment;filename=Request-" +
DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
this.Page.Response.ContentType = "application/ms-infopath.xml";
this.Page.Response.Write(xml);
this.Page.Response.Flush();
this.Page.Response.End();
}
}