SOLVED

Re: Issue with embedding a Forms 2.0 form in an aspx page

Go to solution
Anonymous
Not applicable
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.
Tags (1)
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.  

View solution in original post

9 REPLIES 9
Veronica_Holme4
Level 10 - Champion Alumni
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?
Roger_Willis1
Level 1
Very nice! This solved my problem as well!

-roger
Anonymous
Not applicable
Whoops.  Error on my part as I was typing that up.  Good catch!

Glad that works for you.
Anonymous
Not applicable
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
Anonymous
Not applicable

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.  
Anonymous
Not applicable
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).
Edward_Masson
Level 10
Marketo has updated the Developers site with new info regarding embeding Forms 2.0
http://developers.marketo.com/documentation/websites/forms-2-0/
Anonymous
Not applicable
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.

Alok_Ramsisaria
Level 10

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!