Skip to main content
Feb 10, 2014 7:37 AM UTC
Solved

Issue with embedding a Forms 2.0 form in an aspx page

Our CMS is ASP.NET based, and thus renders an aspx page as a webform.

The issue I'm having is that Forms 2.0 forms don't display.
I'm guessing this has something to do with the fact that the embed code contains a <form> tag, which is within the asp.net <form> tag (and thus creating a nested form - that isn't allowed).

Note: if I change the embed code to show as a lightbox it will show. But that isn't really an option for our site.

Had anyone else run into this issue?

Any suggestions as to how I might get around it?

Thanks heaps.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Accepted solution
Feb 18, 2014 7:41 PM UTC

Hey Craig...

The below should help.

Given a standard embed code:

<script src="//app-sjqe.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1001"></form>
<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "128-IAV-911", 1032);</script>

Make changes to the above such that...

<script src="//app-sjqe.marketo.com/js/forms2/js/forms2.js"></script>
<div id="formPlaceholder"></div>
<form id="mktoForm_1032"></form>
<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "128-IAV-911", 1032, function (form){
MktoForms2.$("#formPlaceholder").append(form.getFormElem());
});</script>

The changes to the original embed code are bolded above.  

This changes the HTML snippet that you insert to not include a form tag and should solve the issues you're having.  

You can change the name of the div id to something more palatable given context of your page.  

9 replies

Level 10
Feb 11, 2014 1:52 PM UTC

Hi Craig


Could you check if the slashes(//) in your embedded code are preceded by "https:"? If not, try adding "https:" before the slashes(//).

Hope this helps!
Translate
Feb 11, 2014 9:30 PM UTC
Hi Alok,

Thanks for the reply.

I tried that, but it didn't fix it.

I'm pretty sure the issue is that the embed code includes a form, and that causes nested forms (due to it being in an ASP.NET page). And browsers won't allow more than one form at a time to render.

I suspect this is going to be a problem for anyone who uses an ASP.net based site... will be interesting to see what solution Marketo provide for this, since it will affect a lot of the big .NET content management systems.

Thanks anyway.

Translate
Edward_Masson
Level 10
Feb 11, 2014 9:49 PM UTC
Marketo has updated the Developers site with new info regarding embeding Forms 2.0
http://developers.marketo.com/documentation/websites/forms-2-0/
Translate
Feb 11, 2014 11:15 PM UTC
Thanks Edward,

I had checked the developer site previously, but it doesn't help unfortunately.

That article just covers how to customise the form when it shows, it doesn't actually have a solution for the form not showing at all. The issue is that the <form> tag in the embed code won't work in aspx pages (since ASP.net already uses a form for its rendering, and you can't have 2 form tags on a page visible at once).
Translate
Accepted solution
Feb 18, 2014 7:41 PM UTC

Hey Craig...

The below should help.

Given a standard embed code:

<script src="//app-sjqe.marketo.com/js/forms2/js/forms2.js"></script>
<form id="mktoForm_1001"></form>
<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "128-IAV-911", 1032);</script>

Make changes to the above such that...

<script src="//app-sjqe.marketo.com/js/forms2/js/forms2.js"></script>
<div id="formPlaceholder"></div>
<form id="mktoForm_1032"></form>
<script>MktoForms2.loadForm("//app-sjqe.marketo.com", "128-IAV-911", 1032, function (form){
MktoForms2.$("#formPlaceholder").append(form.getFormElem());
});</script>

The changes to the original embed code are bolded above.  

This changes the HTML snippet that you insert to not include a form tag and should solve the issues you're having.  

You can change the name of the div id to something more palatable given context of your page.  
Translate
Feb 19, 2014 12:04 AM UTC
Oooh nice work Jason! That works! Many thanks.

One little edit though - in your changed code snippet you still had the <form id> tag in there, but I took that out.

Many thanks for your help.

Craig
Translate
Feb 19, 2014 12:49 AM UTC
Whoops.  Error on my part as I was typing that up.  Good catch!

Glad that works for you.
Translate
Level 1
Mar 7, 2014 6:50 PM UTC
Very nice! This solved my problem as well!

-roger
Translate
Veronica_Holme4
Level 9
Jun 23, 2014 11:58 PM UTC
Hi guys - I'm using this code which does work, but has anyone else experienced an issue with the form repeating on the page when this method is used? i've experienced it twice now, it does not happen with the embed code out of the box, was wondering if anyone else has seen and it and preferably, has anybody else fixed it?
Translate