Input and output - Demonstration

In the following demonstration, the MForm form interacts with a TextBox control, which is the source of form data input, and the dump for xml data output. Input and output work on button pressing.

To make the example work, the ValidateRequest property of the page is set to false. Otherwise, the TextBox could not contain xml data. It is not advised to use such a code in real-life applications.

XML input
 
Simple Test
Leaf Element
Branch Element
leaf Attribute
XML output

        
Input and output - Description

What is important, when using MForm controls, is that they do not modify the input provided. Instead, the output is generated as a new XmlDocument.

In most of the scenarios, the input xml will be provided to the Root control and the output will be taken from there. The input can be set using the DataSource or DataSourceId properties. See here for more details.

Providing input

The content of the MForm is preserved on PostBack. It is not needed to load input xml to MForm on each page load. In case the DataSource property is set on Postback, it clears the previous PostBack data.

It is planned to have all the OffspringItem controls accepting the DataSource. This would make it possible to create MForm out of more than one data source. Each OffspringItem already contains the property DataSource, which expects any IXPathNavigable. However currently the functionality is limited to the initial page run (setting data sources for inner items will not work on PostBack)

Manipulating output

The output can be taken from the Root control using the OutputXml and OutputXmlWithLeftNodes properties.

However, one can get the output fron an of OffspringItem controls, using the GetOutputXml and GetOutputXmlWithLeftNodes extension methods.