# Using the JavaScript embed with ASP.net Forms

**URL:** https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553
**Category:** Setup & Indexing
**Created:** [January 30, 2018, 5:32pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553 "2018-01-30T17:32:21Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![cpatton](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cpatton](https://community.swiftype.com/u/cpatton)
#### Post date: [January 30, 2018, 5:32pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/1 "2018-01-30T17:32:21Z")

</div>

Some [ASP.net](http://ASP.net) pages are wrapped in tags, which can cause conflicts with our JavaScript embed/widget code.  
The most common issue that arises is that our embed will take over the form and provide search results instead of submitting the form.

You can resolve this issue by adding a line of code to our embed script:

```nohighlight
_st('onInstallReady', function() { $stjq('form').off('submit'); });

```

The end result should look a bit like this:

```nohighlight
_st('install', 'YOUR_INSTALL_KEY', '2.0.0'); 
_st('onInstallReady', function() { $stjq('form').off('submit'); });

```

**Note:** This workaround is automatically applied to forms with a `name` or `id` attribute of `"aspnetForm"`.  
Example 1:

```nohighlight
<form name="aspnetForm">
</form>

```

Example 2:

```nohighlight
<form id="aspnetForm">
</form>

```

---

<div class="post-metadata">

### Author: ![j.vanblokland](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@j.vanblokland](https://community.swiftype.com/u/j.vanblokland)
#### Post date: [February 6, 2018, 2:23pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/2 "2018-02-06T14:23:41Z")

</div>

Hi Caitlin, thank you for the response.

So if I understand you correctly, there are two options:

1. Remove the eventhandler of the form using the $stjq(‘form’).off(‘submit’)

- or -

1. add an id or name to the form.

Both seem valid options to consider for us. Thank you.

---

<div class="post-metadata">

### Author: ![cpatton](https://avatars.discourse-cdn.com/v4/letter/c/f04885/32.png) [@cpatton](https://community.swiftype.com/u/cpatton)
#### Post date: [February 7, 2018, 9:09pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/3 "2018-02-07T21:09:50Z")

</div>

No problem! I’m glad you found this snippet useful. 🙂

Yes, those are the two options available for keeping our embed from overriding the behavior of [ASP.net](http://ASP.net) forms.

---

<div class="post-metadata">

### Author: ![kai.sounthala](https://avatars.discourse-cdn.com/v4/letter/k/ed655f/32.png) [@kai.sounthala](https://community.swiftype.com/u/kai.sounthala)
#### Post date: [February 7, 2018, 11:28pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/4 "2018-02-07T23:28:43Z")

</div>

I see this error on my page console - Swiftype widget code has already been included, please only include one on every page.

---

<div class="post-metadata">

### Author: ![j.vanblokland](https://avatars.discourse-cdn.com/v4/letter/j/c57346/32.png) [@j.vanblokland](https://community.swiftype.com/u/j.vanblokland)
#### Post date: [February 13, 2018, 10:14am UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/5 "2018-02-13T10:14:24Z")

</div>

> [@kai.sounthala](#):
>
> Swiftype widget code has already been included, please only include one on every page.

Is this related to the code provided above? Seems to be something else.

---

<div class="post-metadata">

### Author: ![sdonecker23](https://avatars.discourse-cdn.com/v4/letter/s/71e660/32.png) [@sdonecker23](https://community.swiftype.com/u/sdonecker23)
#### Post date: [February 23, 2018, 4:05pm UTC](https://community.swiftype.com/t/using-the-javascript-embed-with-asp-net-forms/553/7 "2018-02-23T16:05:20Z")

</div>

This same issue affects my PHP forms; although my PHP forms already have ids associated with them. If I remove the event handler in the embed code for Swiftype though, my PHP forms work, but it breaks my search function and simply refreshes the page when I click “Search”.

_Edit_ - I added the name tag of “aspnetForm” to my PHP forms, and it fixes both my forms and the search function. However, when I use the search function on a page with a form on it, if I click the search button, it pastes my search criteria into all of the form input boxes, lol.
