Embeddable Search

It's Easy!

Embedding a search in a web page is really straightforward, all you need to do is drop a couple of lines of code pointing to an available Cadcorp Notice Board™ site!

See the online help here for more information.

If you can't see a search bar above, just edit line 25 of this file to point to your instance of Cadcorp Notice Board™ site:

<script src="http://YOURSERVER/YOURWEBSITE/GetSearch.axd?embeddedControlId=mySearch&controlTagId=searchPlaceholderTag&showgeolocate=true&noticeboardUrl=../noticeboard.aspx" type="text/javascript"></script>

The embedded search bar uses AJAX to get results from a web service. The website embedding the search bar AND the Notice Board™ website MUST be in the same domain or you have to enable Cross-Origin Resource Sharing (cors) in you noticeboard website.

There are 2 mandatory parameters that must be added to the url, they are:

  • controlTagId: This is the id of the element that the search bar will be added to, for example to add the search bar to this element:
    <div id="SearchElement"></div>
    the controlTagID would be SearchElement
  • embeddedControlId: This is the id of the for the search bar, it must be unique.

There are several other parameter that can be added to the url to control the behaviour of the search bar

  • delay: The delay in milliseconds that the search bar will wait after the user has finished typing until a search is performed
  • showgeolocate: Set to true to show the geolocate button. If geolocate is not required omit it or set it to false
  • noticeboardUrl: The url to the noticeboard application. It must be encoded
  • initialamountofresultstofetch: The amount of results that will be retrieved when the search is first performed
  • extraresultstofetch: The amount of result to fetch when the 'More' button is clicked
  • searchSelectHandler: define your own event handler function for Result Selected event
  • searches: A comma delimited list of search ids to use, if missing or empty all the searches will be used
  • osopenname: A comma delimited list of OS Open Name search ids to use, if missing or empty all the OS Open Name searches will be used
  • osplaces: A comma delimited list of OS Place search ids to use, if missing or empty all the OS Place searches will be used

Finally a change must be made in the web.config file in your Notice Board™ directory.
At the bottom of the web.config there is a block of code which is commented out by default:
<!-- Allow Cross Origin Resource Sharing (cors) for QuickSearch.asmx-->
<!-- <location path="QuickSearch.asmx">
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
<add name="Access-Control-Request-Method" value="GET,POST,OPTIONS" />
<add name="Access-Control-Allow-Headers" value="Origin, X-Requested-With, Content-Type, Accept" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location> -->

To remove the comment delete <!-- from <!-- <location
and --> from the closing </location> -->