I want to display submitted Xform Data in redirected page or ThankYou Page
If you're using the redirected page function in xforms there are no good way to do so since it makes a normal redirect.
I would suggest that you override that part in the xform handling and add a reference to the posted data as query string and redirect.
on the thank you page you could have a speck fix page type or a block capable to read the posted data.
are you using MVC or Webforms?
I am using webforms.
How to read the Posted data in the page or block..
In the frontend use
<EPiServer:XFormControl id="XFormControl" runat="server" />
And in the backend apply the form and hook up to the AfterSubmitPostedData event to get the form information in OnInit.
protected override void OnInit(EventArgs e)
XForm xForm = CurrentBlock.Form;
this.XFormControl.FormDefinition = xForm;
this.XFormControl.AfterSubmitPostedData += XFormControlOnAfterSubmitPostedData;
private void XFormControlOnAfterSubmitPostedData(object sender, SaveFormDataEventArgs saveFormDataEventArgs)
XFormData xFormData = saveFormDataEventArgs.FormData;
Guid formId = xFormData.FormId;
Guid formDataId = (Guid)xFormData.Id;
In the event, add formId and formDataId as query strings when redirecting to your page.
You can also in that event read the posted information by using formData.GetValue["NameOfField"] where NameOfField represents the name given to the fields in the XForm editor, or formData.GetValues() to get a list of all data.
Note that the keys are the Name, not the visitor friendly label of each field. This might not be usable for the visitor to read.
Reading posted data after redirect
After your redirect, simply use XFormData.CreateInstance to get your posted data.
Guid formId = Guid.Parse(Request.QueryString["formId"]);
Guid formDataId = Guid.Parse(Request.QueryString["formId"]);
XForm xForm = XForm.CreateInstance(formId);
SerializableXmlDocument document = xForm.document;
XFormData xFormData = XFormData.CreateInstance(formDataId, formId);
Here you can find the XFormData with the same information as when the visitor posted the form.
In the xform.Document you should also be able to parse the XML to find the fields and their labels that could be good to display for the visitor.
Thanks Alf Nilsson. It was very useful to me.