ElegantCode Site Search Control

Since migrating to dasBlog, I have had several requests for this
control that was lost during the migration, so I am reposting the readme for this
article here. — 6/15/05


I have wanted to add search to my blog for a long time, therefore
I finally broke down and wrote an implementation in .Net using the
Google Web
Service API.

I am making this control available to the community for use on
your web site.  Although this control is in Beta.  I am ready to solicite
feedback from potential users.  Please email me with comments or suggestions
at
[email protected] or
leave feedback on this page.


What Is This?

ElegantCode.SiteSearch is an ASP.Net server control that  adds
a search box to your ASP.Net application, allowing a user to search your site via
the Google search APIs.  The search results page is fully customizable via XSLT.

Using the Google API

You must sign up with Google here for
a key to their APIs in order to use my control.  It is quite an easy process
and doesn’t take long.  You will need the key they provide in order for this
control to work.

Google currently only allows 1000 searches per day per key, so this
control has the same limitation.  If I start running out of searches at that
rate, I will consider myself lucky.

The Google API is a beta at this time, so that may also be a factor
in your decision to use the control.  I have every intention of updating this
control as the Google APIs go gold.

SiteSearch Installation

Download
the Control Here

  1. Copy ElegantCode.SiteSearch.dll to the /bin directory
    of your ASP.Net application.

  2. Open for edit your web.config file.

    Place the following

    line in your httpModules section.

    <httpHandlers> <add 
    
    verb="*" path="ECSearch.axd"
    type="ElegantCode.SiteSearch.SiteSearchHandler, ElegantCode.SiteSearch" />
    HTTPHANDLERS</httpHandlers>



    Save and close.

  3. Copy the SearchResults.xslt file to a location
    on your web server.

  4. Open for edit the file in which you wish to place the search
    control, for instance an ASPX or ASCX file.  Place the following line at the
    top of your file.

    <%@ Register
    TagPrefix=”cc1″ Namespace=”ElegantCode.SiteSearch” Assembly=”ElegantCode.SiteSearch” %
    >


    Place the following control declaration in the place where you
    want the control to appear.

    <cc1:SiteSearchControl

      id=”SiteSearch”

            ButtonText=”Go”

            InputWidth=”150″

            GoogleLicense=”[Your
    Google License Number]”

            XsltUrl=”~/[Your
    Path]/SearchResults.xslt”

            runat=”server”>
    cc1:SiteSearchControl>


    Where the attributes are used as follows:

    ButtonText The text that you want to appear on the button that a
    user clicks to invoke search.  Default is “Search“.

    InputWidth The width in pixels of the text box into which users will
    type their search terms.  Default is 100 pixels.

    GoogleLicense The license key that Google mailed to you when you
    signed up to use their API.

    XsltUrl Virtual path to the XSLT file that you placed under
    your VROOT.  If the path to my XSLT is:

    /DotTextWeb/ElegantCode/XSLT/SearchResults.xslt

    Then the path I would put in the property would be:
    ~/ElegantCode/XSLT/SearchResults.xslt

    The path that you put in here will be submitted to Server.MapPath().>

Save and close the file.  You
should now see the control rendered in the place where you placed the server tags. Search
should now work.  If you get search results, they will be wrapped in HTML that
makes the page look like it is part of ElegantCode.com.


>

Customize Your Search Results Page

The search results page is imply the result of an XSLT transformation
of the serialized Google results object.  Customizing your search results page
is a matter of modifying or replacing the XSLT that you pointed your control during
implementation.

There are comments in the XSLT file that should give you a head
start in customizing your search results formatting.

 

>>>

One thought on “ElegantCode Site Search Control

Comments are closed.

Proudly powered by WordPress | Theme: Code Blog by Crimson Themes.