Using the JavaScript embed with ASP.net Forms

Some 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:

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

The end result should look a bit like this:

_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:

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

Example 2:

<form id="aspnetForm">
</form>
1 Like

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.

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

Yes, those are the two options available for keeping our embed from overriding the behavior of ASP.net forms.

I see this error on my page console - 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.

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.