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.
/johan
Hi Johan.
I tried out with LINQ to XML yesterday and it worked fine. Thanks for the help!
Br, Tore
Hi!
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);
}
Regards
Linus Ekström
EPiServer Development Team
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
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.
Regards
Linus
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
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?
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
Hi.
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