Copied to clipboard

Flag this post as spam?

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


  • aaronb 97 posts 116 karma points
    Sep 21, 2009 @ 21:16
    aaronb
    0

    .net form control, redirect on form submission?

    I have a site where I need to have users check an "I accept" box, before hitting submit. Provided the box was checked, it will send the user to a specified page.

    I'm trying to modify the runway contact form as my starting point since it's the only .net control macro I've used, but I'm stuck on how to get it to take the user to a new page vs. send the email.

    I do have access to some .net developers, but nobody who has developed for umbraco. If anyone could point me in the right direction on how to achieve this (or what to ask them), that would be fantastic.

     

  • Sebastiaan Janssen 5061 posts 15523 karma points MVP admin hq
    Sep 21, 2009 @ 21:22
    Sebastiaan Janssen
    0

    I don't know how the runway package handles this, but it should eventually do a Page.IsValid after the button click event. You could check for chechbox1.Checked == true together with Page.IsValid.

    If they are both true then you can send the email and after that do a response.redirect.

  • aaronb 97 posts 116 karma points
    Sep 21, 2009 @ 22:34
    aaronb
    0

    Thanks very much - from what I can tell it does indeed use a Page.IsValid function at the end, which contains the sendmail stuff. I don't actuyally need to send the mail, so I could in theory replace the sendmail stuff with a response.redirect?

  • bhunt 18 posts 22 karma points
    Sep 21, 2009 @ 23:20
    bhunt
    0

    To force users to accept the terms, here is what I do.

     

    1) at the top of the .ascx control file, add this:

    <script language="javascript" type="text/javascript">
        function ValidateCheckBox1(source, args)
        {
            args.IsValid = document.getElementById('<%= CheckBox1.ClientID %>').checked;
        }
    </script>

    2) In the form, down near the submit button, add this:

    <asp:CheckBox ID="CheckBox1" runat="server" /> By checking this check box, I agree that I have read and understand the "<a href="javascript: void(0)" onclick="window.open('/consent-for-exercise.aspx','windowname1', 'width=500, height=500,scrollbars=yes'); return false;">Consent for Exercise</a>" information and voluntarily consent to participate in  programs. (Click the link to open the terms in a new window.)
                    <asp:CustomValidator ID="valTandCs" ClientValidationFunction="ValidateCheckBox1" runat="server" ErrorMessage="Please check the box to indicate you agree to the terms."></asp:CustomValidator>

     

  • aaronb 97 posts 116 karma points
    Sep 21, 2009 @ 23:25
    aaronb
    0

    That's a huge help, thank you. One more question - if I set this up as a macro pointing to the ascx file, am I able to use a content picker to tell it which page to redirect to?

    I'm not totally clear from the code snippets where I'd go about setting up how it points to a new page once sucessfully submitted.

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Sep 22, 2009 @ 09:08
    Dirk De Grave
    0

    Hi aaronb,

    Yes, you can pass macro parameters to your user control. Define your paramater (on the parameter tab), set it to content picker type. Add a public property to your user control with the same name as the alias of your newly defined parameter. umbraco will pass that value automagically. In your user control, you can use that value to redirect to the page you like.

    Remember: if using a content picker, the public property should be an integer and umbraco will pass the id of the page, you'll need NiceUrl() to get the page url.

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft