Modify fields of an InfoPath Form Programmatically


   1: const string _InfoPathTemplateLocation = @"http://moss2007/ctype/myFormLibrary/FormServerTemplates/myForm.xsn";
   2: const string _InfoPathPI_mso_infoPathSolution = "name="urn:schemas-microsoft-com:office:infopath:myForm:-myXSD-2008-08-07T17-35-58" solutionVersion="1.0.0.316" productVersion="12.0.0.0" PIVersion="1.0.0.0" href=""
   3:                                                 + _InfoPathTemplateLocation + """;
   4: const string _InfoPathPI_mso_application = "progid="InfoPath.Document" versionProgid="InfoPath.Document.2" />";
   5: const string _InfoPathPI_mso_infoPath_file_attachment_present = "";
   6: 
   7: private void createmyForm()
   8: {
   9: 
  10:     MemoryStream msSr = new MemoryStream();
  11: 
  12:     xmlTextWriter = new XmlTextWriter(msSr, System.Text.Encoding.UTF8);
  13: 
  14:     xmlTextWriter.WriteProcessingInstruction("mso-infoPathSolution",
  15:             _InfoPathPI_mso_infoPathSolution);
  16: 
  17:     xmlTextWriter.WriteProcessingInstruction("mso-application",
  18:         _InfoPathPI_mso_application);
  19: 
  20:     xmlTextWriter.WriteProcessingInstruction("mso-infoPath-file-attachment-present",
  21:     InfoPathPI_mso_infoPath_file_attachment_present);
  22: 
  23:     fields.FirstName= "Mungeri";
  24:     fields.LastName = "Lal";
  25:     fields.Description = "Beautiful Dreams";
  26: 
  27:     XmlSerializer serializer = new XmlSerializer(typeof(myForm));
  28: 
  29:     serializer.Serialize(xmlTextWriter, fields);
  30: 
  31:     xmlTextWriter.Flush();
  32: 
  33: }
Advertisements

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: