Try our conversational search powered by Generative AI!

Redirect after the click of XForm Submit Button

Vote:
 

Hi,

I have an XForm. After the Submit click of Xform the mpage must be redirected to another page. This must be handled from code behind.

I used  EPiServer.XForms.WebControls.Submit.SEND_TO_CUSTOM_URL. But still the page is not getting redirected. Can someone suggest the code.

Regards,

Reena 

 

 

#19589
Apr 21, 2008 9:19
Vote:
 

Hi

If you look in the XForm.ascx in the sample template package ( the control can be found in the folder /Templates/Public/Units/Placeable ) you can find an example on how it can be done.

Basically what you do is to attach to the AfterSubmitPostedData event of your XFormControl. There you can just do a redirect to the PageReference found in FormDefinition.PageAfterPost in your XFormControl.

#19590
Apr 21, 2008 9:33
Vote:
 

Hi

Thanks for the reply. I tried it. But its not able to find the  XForm from the page, thereby no form is displayed.

The code is as follows:

<XForms:XFormControl id="FormControl" runat="server" EnableClientScript = "true"/>

Code Behind:

protected override void OnInit(EventArgs e){

     base.OnInit(e);

     Form.PageId = CurrentPage.Pagelink.Id;

     FormControl.FormDefinition =Form;

    FormControl.AfterSubmitPostedData + = new SaveFormDataEventHandler(FormControl_AfterSubmitPostedData);

}

 

#19595
Apr 21, 2008 14:07
Vote:
 

Hi!

The code in the public templates defines the name of the xform property in the page markup while defining the xform.ascx control. Make sure that you have this defined or change the logic in your ascx file so that you define the name of your xform property.

Regarding the redirect to another page after successfully posting the form this is built in functionality in EPiServer. Just define the page after post when editing the post. The actual redirect in done in the code behind of the xform user control by attaching to the AfterSubmitPostedData event.

Regards
Linus Ekström
EPiServer Development Team

#19702
Apr 28, 2008 14:59
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.