Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rasmus Lynggaard 118 posts 325 karma points
    May 07, 2010 @ 16:10
    Rasmus Lynggaard
    0

    How to redirect on submit?

    How can I make Contour reload (redirect) the page that the form is on when submitting the form succesfully?

  • Rasmus Lynggaard 118 posts 325 karma points
    May 07, 2010 @ 17:09
    Rasmus Lynggaard
    2

    Just read the documentation. Eventhandlers are so nice.... :-)
    I did it like this:

        public class FormRecordEventHandler : umbraco.BusinessLogic.ApplicationBase
        {
            public FormRecordEventHandler()
            {
                RecordService.RecordApproved += new System.EventHandler<RecordEventArgs>(RecordService_RecordApproved);
            }

            void RecordService_RecordApproved(object sender, RecordEventArgs e)
            {
                var r = (Record) ((RecordService)sender).Record;
                if(e.Form.Name == "Comment Form")
                    HttpContext.Current.Response.Redirect(string.Format("{0}#{1}", umbraco.library.NiceUrl(r.UmbracoPageId), r.Id));
            }
        }

  • Jason Prothero 422 posts 1243 karma points c-trib
    May 21, 2010 @ 23:43
    Jason Prothero
    0

    Thanks for this!

  • Jason Prothero 422 posts 1243 karma points c-trib
    May 24, 2010 @ 00:11
    Jason Prothero
    0

    Note: don't tie to the submit event to redirect because the form won't submit to Contour.  Must use the approved event.

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    May 25, 2010 @ 13:54
    Tim
    1

    You can do it in the settings for the umbraco form in the form properties, use the content picker to specify the page you want the form to redirect to, no need to write any custom code.

  • Søren Reinke 158 posts 206 karma points c-trib
    May 31, 2010 @ 13:41
    Søren Reinke
    0

    Hi Tim.

    What to do, if i want the current page to reload after a submit?

    Do i have to use event there ?

  • Rasmus Lynggaard 118 posts 325 karma points
    Jun 17, 2010 @ 10:49
    Rasmus Lynggaard
    0

    @Tim: As I understand you can pnly "hardcode" which page to redirect to, not to the page itself, which is what I needed, because the form is on multiple pages.

  • Tim 1193 posts 2675 karma points MVP 3x c-trib
    Jun 18, 2010 @ 00:21
    Tim
    0

    @Soren, the page would reload on submit anyway, but if you were going to show something dependant on the submission (if say you were using it for blog comments), then you could either set the form to redirect to the page its on in contour (if the form is only on the one page), if the form is going to be on multiple pages, then the events option outlined earlier would probably be best.

    @Rasmus, you're right, contour only lets you choose the one page, so in that case, events is the way to go.

    :)

  • Søren Reinke 158 posts 206 karma points c-trib
    Jun 18, 2010 @ 08:46
    Søren Reinke
    0

    I ended up solving it by using an Event.

Please Sign in or register to post replies

Write your reply to:

Draft