Copied to clipboard

Flag this post as spam?

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


  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 02, 2009 @ 15:17
    Jan Skovgaard
    0

    Having more than one form on a page...

    Hi people

    First off I'm not sure whether this is the right category or not.

    I am currently using the Umbraco pacakge subscribeunsubscribe to register people who want's to subscribe to a newsletter.

    The newsletter form is placed in the master template, since it should be available on all pages. There is also a search form on the master template. And when things get really crazy there's also a form to handle unsubscription of the newsletter.

    My question is...how can I have more than one form on a page? I know that there are some issues regarding this in asp.net but I don't know what to do to solve them.

    Is it at all possible for me to do so when using the subscribeunsubscribe package?

    /Jan

  • Nik Wahlberg 639 posts 1237 karma points MVP
    Dec 02, 2009 @ 15:23
    Nik Wahlberg
    0

    pretty common issue actually. Here's a thread that might help.

    http://our.umbraco.org/forum/developers/extending-umbraco/5360-Two-forms-on-the-same-page

    Thanks,
    Nik

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 02, 2009 @ 15:29
    Jan Skovgaard
    0

    Thanks Nik...I'll try the stuff mentioned there and post additional questions there if they should arise :)

    /Jan

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Dec 02, 2009 @ 15:46
    Morten Christensen
    0

    I have seen the discussion on the link that Nik provided, but why not simply create a usercontrol with an input field and a button as your Newsletter signup (macro) - insert the usercontrol as a macro on your masterpage. Put an OnClick event on the button and handle it in your codebehind when the button is clicked...?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 02, 2009 @ 16:23
    Jan Skovgaard
    0

    @Morten

    Hmmm, yes you are probably right that this is the best solution. But I'm not that skilled on .NET yet so I'm not so sure about what I should write in the OnClick event though? :)

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Dec 02, 2009 @ 16:27
    Morten Christensen
    0

    If you can drop me an email with your current masterpage and current form fields and where they should post to I can quickly make you a usercontrol that does what you need. I can also email you an example if you prefer.

    I'll DM you my email.

    - Morten

  • Morten Christensen 596 posts 2773 karma points admin hq c-trib
    Dec 02, 2009 @ 20:30
    Morten Christensen
    1

    Hi Jan, this is an example of what I would do:

    In your UserControl (.ascx):

    <asp:TextBox ID="TbEmail" runat="server"></asp:TextBox>
    <asp:RadioButtonList ID="RblSubscribe" runat="server">
    <asp:ListItem Value="Subscribe">Subscribe</asp:ListItem>
    <asp:ListItem Value="Unsubscribe">Unsubscribe</asp:ListItem>
    </asp:RadioButtonList>
    <asp:Button ID="BtnSubmit" runat="server" OnClick="BtnSubmit_OnClick" Text="Submit" />

    Codebehind (.ascx.cs):

    protected void BtnSubmit_OnClick(object sender, EventArgs e)
    {
    //Check email exists
    string email = TbEmail.Text;
    if(RblSubscribe.SelectedValue.Equals("Subscribe"))
    {
    //Subscribe the entered email
    }
    else
    {
    //Unsubscribe the entered email
    }
    }

    Create a macro for this usercontrol and put it on your masterpage - should work fine.

    There could be some challenge as to which form event will be fired if the user hits enter instead of clicking the Submit or Search button, but you'll have to test that and there is different ways to fix it.

    Hope this helps you out, otherwise let me know ;)

    - Morten

Please Sign in or register to post replies

Write your reply to:

Draft