Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
Hi,
im trying to create a xForm on a page and have added the following code into it's type class:
/// <summary> /// Gets or sets the form. /// </summary> /// <value>The form.</value> [Display( Name = "Form", Description = "A Simple Form builder.", GroupName = SystemTabNames.Content, Order = 1)] [CultureSpecific] public virtual XForm Schema { get; set; }
On the page itself I have added the following:
if (CurrentPage.Schema != null) { XFormControl.FormDefinition = CurrentPage.Schema; XFormControl.AfterSubmitPostedData += new SaveFormDataEventHandler(FormControl_AfterSubmitPostedData); }
AND
public void FormControl_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e) { XFormControl control = (XFormControl)sender; var clone = e.FormData.Data.Clone(); try { // EmailHelper.SendUserEmail(control.Data, CurrentPage); if (control.FormDefinition.PageGuidAfterPost != Guid.Empty) { var pageMap = PermanentLinkMapStore.Find(control.FormDefinition.PageGuidAfterPost) as PermanentPageLinkMap; if (pageMap != null) { control.Page.Response.Redirect(pageMap.MappedUrl.ToString()); return; } } } catch (Exception ex) { throw ex; //Response.Write("ERROR" + ex.ToString()); } //control.Controls.Clear(); System.Web.UI.WebControls.Label label = new System.Web.UI.WebControls.Label(); label.CssClass = "thankyoumessage"; label.Text = "Thank you"; control.Controls.Add(label); }
AND the mark up:
<XForms:XFormControl ID="XFormControl" runat="server" EnableClientScript="false" ValidationGroup="XForm" OnAfterSubmitPostedData="FormControl_AfterSubmitPostedData" />
Yet, when setting the Submit button to either email - database or specific URL, and setting the page it needs to go to after submitting the form doesnt work - have I missed anything?
Jon