Copied to clipboard

Flag this post as spam?

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


  • Iain Martin 54 posts 98 karma points
    Mar 25, 2011 @ 16:22
    Iain Martin
    0

    User Control not posting back?

    I have a user control that is attempting to be used as the BuyNow page for PayPal. I am aware of the issues that are around with the PayPal buttons being inside nested forms in relation to ASP.NET. I know that I could simply use the link with the relevant data to send to PayPal using the buttons PostbackURL property, but the issue is that these are effectively donations and the client wishes to include a dropdown/select with Gift Aid/Without Gift Aid options to be selected. If you create the button on PayPal, using a select does not allow the option of sending by email/link. There is the added complication that they have 4 buttons for the various donation values they want to have, each

    I thought I could write the user control to trap the postback event from the button click and redirect to paypal with a complete URL including the giftaid selection. However, I cannot seem to get the page to acknowledge the post back event at all.

    Here is the code for the  image button on the .ascx page:

    <asp:ImageButton ImageUrl="~/images/donations/donate_five.png" ID="btnFive" runat="server" PostBackUrl="~/donate.aspx" />

    And here is the Page_Load code:

       protected void Page_Load(object sender, EventArgs e)
    {
    if (IsPostBack)
    {
    lblMessage.Text = "I have posted back";
    }
    else
    {
    lblMessage.Text = "I have not posted back";
    }
    }

    As you can see, there is really nothing to it, but I cannot for the life of me get the lblmessage to say 'I have posted Back"!!!!!!

    I'm sure it is something really simple that is doing this, but I can't see what it is.

    The user control is on a template that has 3 parent templates above it - so in effect it is the 4th child page.

    Any ideas what I am doing wrong?

    Regards

    Iain

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Mar 25, 2011 @ 16:42
    Tom Fulton
    0

    Hi Iain,

    Make sure your macro is wrapped in <form runat="server"> tag in your template, ie:

    <form ruant="server">
    ...
    ...
    <umbraco:Macro Alias="blahblah"></umbraco:Macro>
    ...
    ...
    </form>

    -Tom

  • Iain Martin 54 posts 98 karma points
    Mar 25, 2011 @ 17:02
    Iain Martin
    0

    Yeah, that was the first thing I checked and it definetely has the form tag round the whole thing. I have also doubled checked that there are not other forms hiding in the page elsewhere.

  • Laurent Lequenne 122 posts 247 karma points
    Mar 30, 2011 @ 10:34
    Laurent Lequenne
    0

    this

    .Page.ClientScript.GetPostBackEventReference(this, "NEXT")

    If the Javascript code is not in your - Get anything like this in your code, this will register the postback javascript code :-)

    If the postback javascript can be found, check the validation on the page.

    • If multiple forms = use validation groups for validators and submit buttons.
    • If still not working set causesvalidation to false
    • if still not working do not use a button, but a link :-)
    • If still not working use the first line and get the url to put on a link, use the IPostBackEventHandler to catch the "NEXT" Argument :-)
    • If still not working use the good old post and request.form features :-)
    • If you fail in all this... Go to PHP :-)

    A decent message editor in this forum ??? When ?

Please Sign in or register to post replies

Write your reply to:

Draft