/// <summary> /// Handles the AfterSubmitPostedData event of the XFormControl. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EPiServer.XForms.WebControls.SaveFormDataEventArgs"/> instance containing the event data.</param> public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e) { XFormControl control = (XFormControl)sender; if (control.FormDefinition.PageGuidAfterPost != Guid.Empty) { PermanentContentLinkMap pageMap = PermanentLinkMapStore.Find(control.FormDefinition.PageGuidAfterPost) as PermanentContentLinkMap; if (pageMap != null) { string internalUrl = pageMap.MappedUrl.ToString(); internalUrl = UriSupport.AddLanguageSelection(internalUrl, ContentLanguage.PreferredCulture.Name); UrlBuilder urlBuilder = new UrlBuilder(internalUrl); //Rewrite the url to make sure that it gets the friendly url if such a provider has been configured. Global.UrlRewriteProvider.ConvertToExternal(urlBuilder, null, Encoding.UTF8); //Always cast UrlBuilders to get a correctly encoded url since ToString() is for "human" readability. control.Page.Response.Redirect((string)urlBuilder); return; } } //After the form has been posted we remove the form elements and add a "thank you message". control.Controls.Clear(); Label label = new Label(); label.CssClass = "thankyoumessage"; label.Text = LocalizationService.Current.GetString("/form/postedmessage"); control.Controls.Add(label); }
public void FormControl_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e) { if (EnableStatistics) { SwitchView(null, null); SwitchButton.Visible = false; } }
/// <summary> /// Handles the BeforeSubmitPostedData event of the XFormControl. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EPiServer.XForms.WebControls.SaveFormDataEventArgs"/> instance containing the event data.</param> public void XForm_BeforeSubmitPostedData(object sender, SaveFormDataEventArgs e) { XFormControl control = (XFormControl)sender; PageBase currentPage = control.Page as PageBase; if (currentPage == null) { return; } //We set the current page that the form has been posted from //This might differ from the actual page that the form property exists on. e.FormData.PageGuid = currentPage.CurrentPage.PageGuid; }
/// <summary> /// Handles the AfterSubmitPostedData event of the XFormControl. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EPiServer.XForms.WebControls.SaveFormDataEventArgs"/> instance containing the event data.</param> public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e) { XFormControl control = (XFormControl)sender; if (control.FormDefinition.PageGuidAfterPost != Guid.Empty) { PermanentPageLinkMap pageMap = PermanentLinkMapStore.Find(control.FormDefinition.PageGuidAfterPost) as PermanentPageLinkMap; if (pageMap != null) { control.Page.Response.Redirect(pageMap.MappedUrl.ToString()); return; } } //After the form has been posted we remove the form elements and add a "thank you message". control.Controls.Clear(); Label label = new Label(); label.CssClass = "thankyoumessage"; label.Text = LanguageManager.Instance.Translate("/form/postedmessage"); control.Controls.Add(label); }
/// <summary> /// Handles the AfterSubmitPostedData event of the XFormControl. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EPiServer.XForms.WebControls.SaveFormDataEventArgs"/> instance containing the event data.</param> public void XForm_AfterSubmitPostedData(object sender, SaveFormDataEventArgs e) { XFormControl control = (XFormControl)sender; if (control.FormDefinition.PageGuidAfterPost != Guid.Empty) { PageData pageAfterPost; var repo = ServiceLocator.Current.GetInstance <IContentRepository>(); if (repo.TryGet(control.FormDefinition.PageGuidAfterPost, out pageAfterPost)) { control.Page.Response.Redirect(UrlResolver.Current.GetUrl(pageAfterPost.ContentLink, pageAfterPost.Language.Name)); } } //After the form has been posted we remove the form elements and add a "thank you message". control.Controls.Clear(); Label label = new Label(); label.CssClass = "xformthankyoumessage"; label.Text = LocalizationService.Current.GetString("/form/postedmessage"); control.Controls.Add(label); }