Subscribe form from .NET page - do I need API?

Hello, I'm new to all this so hope someone can help with this basic question.

I have a website in ASP.NET (VB) and have tried pasting the code that is generated in 'Manage Subscribers' to create a subscribe form on the page. It doesn't seem to work (subscriber is not registered, and I don't get the 'thank you' message.) Is this because the page is not plain HTML, and is there a simple way around this without having to get into the API?

If API is needed then can anyone point me to a simple example?

Many thanks

Mathew Mathew, 8 years ago

This is most likely because your page already has a <form></form> tag surrounding the entire page content. .Net pages are often setup this way, and it stops the form from submitting properly.

You'll need to either put the signup form on a page without the extra form code, or inside an iframe. Otherwise, you would need to use the API, which might require help from the developers.


Get in touch with us on Twitter: http://twitter.com/campaignmonitor
We're also on Facebook: http://facebook.com/campaignmonitor
EllenD, 8 years ago

Hi Matthew,

Thank you for your reply. Yes my page does already have form tags, and I think this is the reason. After a little more digging, I seem to have been able to achieve the desired result with a response.redirect. Does this look OK to you, it seems to work as far as I can tell.

I'll post the whole code as may be of help to someone else. On a normal .NET page I have two text fields, txtName and txtEmail, and a button with the following on_click code:

-----------------
        Dim name As String
        Dim email As String

        name = Server.UrlEncode(txtName.Text)
        email = Server.UrlEncode(txtEmail.Text)

        Response.Redirect("http://mymailbuildname.createsend.com/t/1/s/urlti/?mb-urlti-urlti=" & email & "&mb-name=" & name)
-----------------

The URL to redirect to and the querystring parameters (mb-urlti-urlti etc) are taken from the HTML which is generated from within Mailbuild.

Comments welcome on whether this method is OK to use?

EllenD, 8 years ago

Just wondering if anyone can confirm, is this a reasonable way of doing the subscription from a .NET page?

Ken Ken, 8 years ago

Hi Ellen,

That should be fine. I think the bit of code you're using is

Response.Redirect("http://mymailbuildname.createsend.com/t/1/s/urlti/?mb-urlti-urlti=" & email & "&mb-name=" & name)

Part of your line was truncated, so I'm just posting the full line so that other people can see it.


http://www.campaignmonitor.com
EllenD, 8 years ago

Hi Ken,

Thanks very much, it does seem to work fine but just thought I'd check!

Ellen

hipsterdoofus, 7 years ago
Ken :

Hi Ellen,

That should be fine. I think the bit of code you're using is

Response.Redirect("http://mymailbuildname.createsend.com/t/1/s/urlti/?mb-urlti-urlti=" & email & "&mb-name=" & name)

Part of your line was truncated, so I'm just posting the full line so that other people can see it.

Ken,

I have a follow-up question regarding the .NET redirect code for custom fields. I have two custom fields I'm trying to capture. I've tried appending the variable name from the "name" attribute of the custom field to the code above along with the variable from the corresponding text box. While the subscribe requests seem to be going through including the name and email, the custom field values are not. Can you tell me if I'm submitting the custom field values incorrectly? Example below:
       

 clinID = Server.UrlEncode(txtClinicID.Text)
        clin = Server.UrlEncode(txtClinic.Text)

        Response.Redirect("http://mymailbuildname.createsend.com/t/r/s/vuhkt/?cm-vuhkt-vuhkt=" & email & "&cm-name=" & name & "&cm-f-uitkk=" & clinID & "&cm-f-oklll=" & clin)

Thanks for any help you can provide.

hipsterdoofus, 7 years ago
hipsterdoofus :

Ken,

I have a follow-up question regarding the .NET redirect code for custom fields. I have two custom fields I'm trying to capture. I've tried appending the variable name from the "name" attribute of the custom field to the code above along with the variable from the corresponding text box. While the subscribe requests seem to be going through including the name and email, the custom field values are not. Can you tell me if I'm submitting the custom field values incorrectly? Example below:
       

 clinID = Server.UrlEncode(txtClinicID.Text)
        clin = Server.UrlEncode(txtClinic.Text)

        Response.Redirect("http://mymailbuildname.createsend.com/t/r/s/vuhkt/?cm-vuhkt-vuhkt=" & email & "&cm-name=" & name & "&cm-f-uitkk=" & clinID & "&cm-f-oklll=" & clin)

Thanks for any help you can provide.

As a follow-up for anyone else who is dealing with this: I learned that custom fields are not supported in the querystring submission method. To solve my problem, I implemented the API and used the Subscriber.AddWithCustomFields method.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098