Extract all XForm Controls



I am developing a wizard that contains XForms. Before the data is submitted I want to show a summary page with the entered values. When I use XFormControl.ExtractXFormControls() to get the controls in the XForm I only get the input controls. Is there a way that I can get the label controls as well?

Br, Tore

Sep 28, 2009 9:32

Hi Tore!

The problem is that the labels are not appended to the control collection as server side controls at all (as the input controls are), they're simply rendered as straight xhtml from the XForm Document.

The only way that I see you can get at the label texts would be to use XPath (or something equivalent) to peek into the XForm xml document.


Sep 28, 2009 16:45

Hi Johan.

I tried out with LINQ to XML yesterday and it worked fine. Thanks for the help!

Br, Tore 

Sep 29, 2009 8:03


 It's great that you could solve this yourself. If you are interrested the Label is handled as a sub node in XForms:

<xforms:input class="value" id="Name" title="Your name" ref="Name" required="True">   <xforms:label>Your name:</xforms:label>   </xforms:input>

When the xform content is parsed to server controls the label will be parsed as a sub control to the XForms input control. This value can be accessed either directly from the Label property or the InnerLabel property which has the actual text in it's Value property. Here is a short code sample that shows how to extract the values in a global xforms event handler:

        public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e)
            XFormControl control = (XFormControl)sender;

            List<XFormControlBase> controls = control.ExtractXFormControls();

            foreach (XFormControlBase controlBase in controls)
                control.Page.Response.Write(controlBase.Label + ": " + controlBase.Value);

Linus Ekström
EPiServer Development Team

Sep 30, 2009 15:48

Hi Linus.

Thanks for your answer! That will defiantly solve my problem if the label control is rendered in the same <td> element as the the input control. But what if the controls are rendered in different <td> elements? Will I be able to fetch the label control without parsing the XForm xml document?

Br, Tore Gjerdrum

Sep 30, 2009 16:01

Hi again.

 I assumed that your form fields were using the "Heading" property as labels which is the recomended way to get accessible forms. But if you need to use stand alone labels for visual appearence there is no connection to the actual input control and the label. You can use the Reference property to get the name of the control but if you need to find the actual text from the label then I guess LINQ to XML is probably the right way to do it.


Sep 30, 2009 17:04

Hi Linus.

I wanted the customer to use the "Heading" property as labels, but they wanted a solution that supported both. I will stay with LINQ to XML then. Thanks for your response!

Br, Tore

Sep 30, 2009 17:08

what is FormDefinition in <XForms:XFormControlID="XFormID"FormDefinition=""runat="server"> what value i have to specify? if i give some value in double quotations......it is not accepting saying that it is string thats y......how can i rectify this error in source window?

Jul 07, 2011 13:18

Hi Linus,

I downloaded this editorial manual

url http://world.episerver.com/Documents/Manuals/EPiServer%20CMS/EditorManuals/EPiServer%20CMS%206%20R2/Screen/Editors%20Manual%20EPiServer%20CMS%206%20R2%20%28English%29_LowRes.pdf


But in that no mention of xform. If u dont mind Can u sent me the url of editorial manual which describes the XForm. I tried so many times but i cant able to extract the values in XForm

Jul 11, 2011 10:47

There's an entire section called "Form Pages" which describes this.

Jul 11, 2011 10:49
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.