Click here to Skip to main content
15,886,422 members
Articles / Web Development / ASP.NET
Article

Creating Search Pages with Index Server and .NET

Rate me:
Please Sign up or sign in to vote.
4.74/5 (38 votes)
25 Jan 2003Ms-PL9 min read 705.1K   4.7K   163   238
Combine the ADO.NET techniques you know - and perhaps some you don't know - with the power and flexibility of Microsoft Index Server and ASP.NET to create easy - yet powerful - custom search pages for your Web site.

Introduction

When Index Server was released, it was easy to see that it had potential. A developer could not only index document content, but could easily index document properties and meta-data. To create search pages and result pages, you could use fairly simple IDQ and HTX files. With the inception of ActiveServer Pages (ASP) in Internet Information Server (IIS) 3.0, Index Server 2.0 added server-side helper objects. Finally, OLE DB drivers were added in Index Server 3.0 which was shipped with Windows 2000 so that developers could query Index Server in the same manner that they would query a database. It is this technology that makes powerful custom search pages in ASP.NET easy.

Using the Index Server OLE DB provider with ADO.NET allows us to data-bind results to common ASP.NET WebControls like the DataGrid, Repeater, and more. The simple paging features of these WebControls is also an advantage over previous models when we had to manage paging the results ourselves with server-side conditional statements and multiple forms on a page to handle either POST or GET requests.

This article will show you the techniques involved to create a query and result page in ASP.NET, to add data-bound WebControls to the page, and to allow for advanced query statements while protecting sensitive content.

Before you continue with this article, you should already be familiar with the basic architecture of Index Server, which can be found in the Platform SDK at MSDN. These features will not be discussed in any detail throughout the article.

Create the Search Page

Before designing your search page, you'll first want to consider what document properties and meta-data the user can search and how those results are to be displayed. Typically, the user is allowed to enter a query to search for all words or any words, or that uses boolean expressions, exact expressions, or even natural language expressions. The user should be allowed to select what type of expression their query is, and "All Words" is usually default. It is also good to provide your user a way to limit their search to a particular scope, such as directories containing individual products or departments. This also gives you the ability to use your search page as a target for a UserControl that could appear at the top of each page and sets the scope to match its parent directory. You should also let the user specify how the results are to be sorted and how many appear on a page.

You'll also need to decide how to display the results to the user. Below is a common format and the format that will be used later in this article:

HTML
<a href="[VPath]">[DocTitle]</a>
[Characterization]...
<i><a href="[VPath]">[SERVER_NAME][VPath]</a> - Last Modified: [Write]</i>

Knowing what your results will look like helps determine what control to use. You could use a DataList or Repeater, but then you would have to manage paging yourself. Instead, you might choose to use a DataGrid with a TemplateColumn. Using this approach, you can acheive the same result with the additional paging functionality for virtually free.

Index Server and ADO.NET

When Microsoft added an OLE DB provider to Index Server 3.0 in Windows 2000, they provided developers the means to query Index Server using the same ADO techniques they use to query databases like SQL Server, Oracle, Access, and many more. These techniques are similar in ADO.NET, except ADO.NET presents developers with more features and capabilities like DataSets, or disconnected recordsets. While features of DataSets like primary keys, relationships, and identity columns aren't used in this article, they are worth mentioning.

Supporting ADO and ADO.NET also means that we can query Index Server using SQL statements like any other database. If you take a look at the Indexing Service Reference on MSDN, you'll see that Index Server supports views, batched statements, and all the basic SQL commands you probably know. An example of a SQL statement to select the fields from the above layout would look like:

SQL
SELECT Rank, VPath, DocTitle, Filename, Characterization, Write
FROM SCOPE('DEEP TRAVERSAL OF "/"')
WHERE NOT CONTAINS(VPath, '"_vti_" OR ".config"')
    AND CONTAINS(Contents, '"keyword1" AND "keyword2"')
    AND CONTAINS(DocTitle, '"keyword1" AND "keyword2"')

The SCOPE and CONTAINS keywords may be new to you. The SCOPE function allows us limit our query to a particular directory or directories, and whether or not we want subdirectories included. Where's the database reference? That's implied from the SQL connection string:

Provider=MSIDXS.1;Data Source=Web

The CONTAINS and FREETEXT predicates are available in both Index Server 3.0 and SQL Server 2000 (since both use the same Full-text providers) and allow a user to query a particular column (or even a table) for a keyword or combination of keywords using a boolean expression. Use the CONTAINS predicate to search for the existence of such keywords or the FREETEXT predicate for natural language searches.

The SQL statement above is the basis for the other queries used in the example code, but you can easily extend this sample to search for documents modified or created after certain dates, articles by certain authors (without a lot of work, this currently only applies to Office documents), and much more. You can even search for properties of media files or create your own filters (see the IFilter documentation). Index Server will also index your custom META elements. For information about using custom filters, see Using Custom Filters with Indexing Service on MSDN.

Warning: When designing opened-ended SQL statements, especially those used on the Internet by anonymous users, always be sure to not allow malicious statements to destroy your databases and catalogs. One of the biggest mistakes of webmasters and designers are statement templates like:

SQL
SELECT * FROM Table1 WHERE Field1 =

A condition would then be appended to the statement. So what's wrong with this approach? All it takes is someone to enter a "term" like the following and your day is ruined:

SQL
"asdf"; DELETE FROM Table1;

Think this is unlikely? Think again. Most modern databases support meta-data queries, giving users the ability to find out just about anything about the database and its structure. A user with malicious intent could use a couple queries and potentially delete all data from all your tables or event drop them. So, always design your SQL statement templates with care. Since Index Server supports batched queries separated by semi-colons (";"), I stripped-out any semi-colons so the statement "DELETE FROM Table1" would become no more than three keywords by which to search. This is a very basic way and there are better ways like having more advanced parsing functions, but this is only example and this is left as an exercise for you - although this approach should stop about everything.

You should also pay attention to the first condition in the WHERE clause. Adding this condition causes the query to not return search results for files or directories that contain the terms listed. Use the suggested terms above and add your own to keep a user from seeing sensitive files or directories like your application's "Web.config" file or FrontPage directories like "_vti_cnf". While anonymous users may not be able to view these files or browse these directories directly, they can view sensitive information from the characterizations (summaries) in their search results.

Binding Search Results to a DataGrid

Data-bound controls in ASP.NET are very powerful and can be used in many applications. For this exmaple, we'll bind a DataSet from the query discussed above to a DataGrid and use its powerful paging functionality to let users navigate through pages of the search results. From this point on, almost all the functionality of the example is given to us at minimal development costs.

Remember the search result template at the beginning of the article? This is obviously not a columnar template, so how do we acheive that in a DataGrid? A TemplateColumn allows us to find fields and expressions using HTML as we normally would. To tell the binding container to use a particular expression for binding, we use the <%# %> data binding expression syntax. Such an expression would look like the following:

HTML
<asp:hyperlink runat="server"
    NavigateUrl='<%# DataBinder.Eval(Container.DataItem, "VPath")%>'
    ><%# GetTitle(Container.DataItem)%></asp:hyperlink>

This would display a hyperlink with the document path as the target and the appropriate document title or filename. GetTitle() is a protected method in our code-behind class that determines if DocTitle is available and - if not - returns the Filename instead. As you can see, a binding expression isn't limited to a data-binding expression. See the sample source code for a complete example of the result display format given at the beginning of this article. Feel free to try different layouts or add additional columns, from BoundColumns for a single column to TemplateColumns for custom layouts like the example above. Make sure to set AutoGenerateColumns to false, however, otherwise all selected fields will be output in additional and prior to your user-defined bound columns.

Paging the Results

As mentioned before, using the DataGrid data-bound control to display our search results gives us a paging technique for virtually free. Previous solutions in ASP or even with IDQ/HTX files either forced us to use large GET queries - which can be affected by length restrictions imposed by browsers' address bars - or have multiple forms contained in our page. ASP.NET only allows a page to have one server-side form, although these previous techniques could be accomplished with client-side forms and page-output statements. This can be tedious and ASP.NET presents us with better, object-oriented options.

To handle the paging of data, set AllowPaging to true and add a new event handler for DataGrid.PageIndexChanged event and enter the code below, replacing dgResultsGrid with whatever control name you use:

C#
private void dgResultsGrid_PageIndexChanged(object source, <BR>  DataGridPageChangedEventArgs e)
{
    this.dgResultsGrid.CurrentPageIndex = e.NewPageIndex;
    this.Search(); // A private method that actually starts the search.
}

This will set the start position of the bound source to the DataGrid.CurrentPageIndex multiplied by the DataGrid.PageSize.

You can change the style of the paging used from a page-numbering system like the example uses, form or text buttons, or even custom navigation controls. See the DataGrid Web Server Control documentation on MSDN for more information.

Summary

Using the ADO.NET techniques you already know and use to retrieve results from a database, you can build fast, powerful search pages without a lot of work like that which was required before. The OLE DB provider for Index Server offers you great flexibility and additional functions and predicates that add more great features to your query. Using easy-to-use data-bound controls with which you're already familiar like the DataGrid allow you to display those results quickly and without a lot of code. Combining all three technologies with the simple techniques discussed above and in the sample source code can give your site powerful search capabilities in a short amount of time.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
Software Developer Microsoft
United States United States
Principal Software Engineer currently working on Azure SDKs at Microsoft. My opinions are my own. I work on a number of OSS projects for work and personally in numerous languages including C++, C#, JavaScript, Go, Rust, et. al. See a problem, fix a problem (or at least create an issue)!

Avid outdoor adventurer 🏔️❄️👞🚴‍♂️, husband, father.

Comments and Discussions

 
QuestionPlatform SDK not found Pin
kiquenet.com9-Jun-16 21:55
professionalkiquenet.com9-Jun-16 21:55 
QuestionReferences not found Pin
kiquenet.com9-Jun-16 21:27
professionalkiquenet.com9-Jun-16 21:27 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey28-Feb-12 18:28
professionalManoj Kumar Choubey28-Feb-12 18:28 
GeneralNo Records Return in search Pin
Lymni3-Sep-10 4:10
Lymni3-Sep-10 4:10 
QuestionEliminate certain directory in query Pin
Freeweight3-Jun-10 3:38
Freeweight3-Jun-10 3:38 
AnswerRe: Eliminate certain directory in query Pin
Heath Stewart19-Jul-10 2:20
protectorHeath Stewart19-Jul-10 2:20 
Generalindexing server Pin
venky4562-Oct-07 21:42
venky4562-Oct-07 21:42 
GeneralSpecifying Content to be indexed Pin
ashepherd16-Oct-06 8:04
ashepherd16-Oct-06 8:04 
GeneralAbstracts Pin
ajwelch2-Oct-06 1:51
ajwelch2-Oct-06 1:51 
GeneralRe: Abstracts Pin
Heath Stewart2-Oct-06 16:18
protectorHeath Stewart2-Oct-06 16:18 
GeneralRe: Abstracts Pin
ajwelch2-Oct-06 22:27
ajwelch2-Oct-06 22:27 
GeneralRe: Abstracts Pin
Heath Stewart3-Oct-06 11:26
protectorHeath Stewart3-Oct-06 11:26 
Generalnavigable links not showing up on search results Pin
ajwelch26-Sep-06 0:00
ajwelch26-Sep-06 0:00 
GeneralRe: navigable links not showing up on search results Pin
Heath Stewart26-Sep-06 7:45
protectorHeath Stewart26-Sep-06 7:45 
GeneralRe: navigable links not showing up on search results Pin
ajwelch29-Sep-06 3:46
ajwelch29-Sep-06 3:46 
GeneralRe: navigable links not showing up on search results Pin
ajwelch2-Oct-06 1:48
ajwelch2-Oct-06 1:48 
GeneralPost to search from textbox on another page Pin
ajwelch11-Sep-06 23:46
ajwelch11-Sep-06 23:46 
GeneralRe: Post to search from textbox on another page Pin
Heath Stewart12-Sep-06 6:14
protectorHeath Stewart12-Sep-06 6:14 
GeneralRe: Post to search from textbox on another page Pin
ajwelch18-Sep-06 1:44
ajwelch18-Sep-06 1:44 
GeneralRe: Post to search from textbox on another page Pin
Heath Stewart18-Sep-06 6:22
protectorHeath Stewart18-Sep-06 6:22 
GeneralRe: Post to search from textbox on another page Pin
ajwelch18-Sep-06 6:28
ajwelch18-Sep-06 6:28 
GeneralRe: Post to search from textbox on another page Pin
Heath Stewart18-Sep-06 6:31
protectorHeath Stewart18-Sep-06 6:31 
GeneralRe: Post to search from textbox on another page Pin
ajwelch19-Sep-06 23:17
ajwelch19-Sep-06 23:17 
GeneralRe: Post to search from textbox on another page Pin
Heath Stewart20-Sep-06 7:36
protectorHeath Stewart20-Sep-06 7:36 
GeneralRe: Post to search from textbox on another page [modified] Pin
ajwelch20-Sep-06 22:43
ajwelch20-Sep-06 22:43 
The master page has a <form runat="server"></form> wrapping around the body content.

This is the index page of my website which doesnt use master pages (note I have removed the server.transfer code and replace it with a PostBackUrl in the asp:button tag. This method works and returns search results from the sitesearch.aspx page.)--

-----------------------------------------------------------------------
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">

<!-- Styles for drop downs -->

<style type="text/css">
ul {
margin: 0;
padding: 0;
list-style: none;
}
ul li {
position: relative;
float: left;
width:70px;
}
li ul {
position: absolute;
left: 0; /* Set 1px less than menu width */
top: auto;
display: none;
}
/* Styles for Menu Items */
ul li a {
display: block;
text-decoration: none;
background:white; /*; IE6 Bug */
padding: 5px;
}
/* set dropdown to default */
li:hover li a, li.over li a {
color: #777;
background-color:#fff;
}
li ul li a { padding: 2px 5px; } /* Sub Menu Styles */
li:hover ul, li.over ul { display: block;} /* The magic */
</style>

<!-- Styles for drop downs ends -->

<!-- Javascript for drop downs -->

<script type="text/javascript">
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>

<!-- Javascript for drop downs ends-->

<!-- Javascript for flash object -->

<script type="text/javascript" src="javascript/flashobject.js"></script>

<!-- Javascript for flash object ends-->

<link href="stylesheet1.css" type="text/css" rel="stylesheet">
<title>Welcome to Abtec Network Systems - Complete Communications and Business Network Solutions</title>
<meta content="history, abtec, network solutions, communication solutions, small businessnetworks, pc firewall, network security, LAN, WAN, Wireless, network maintanence, technical support, business network solution" name="keywords">



<meta content="Abtec network systems provides the complete network, business network and communications solutions specalising in telephone systems, network installation and maintenance, LAN, WAN, Wireless and security solutions" name="description">

</head>

<body>



<!-- Top CSS content on page -->

<div style="width: 660px; height: 200px;">

<div style="float: left;">

<a href="index.aspx">

<img style="border: none;" alt="Abtec Network Systems" src="images/topleftabteclogo.gif">

</a>

</div>

<div style="float: left;width: 545px; height: 20px; text-align: left; margin-left:20px;">

<!-- Mini navigation start -->

<div class="navig1" style="">
<table>
<tr>
<td style="height: 16px"><img style="border:none;" alt="abtec network systems" src="images/email.gif"><a href="contact.aspx" style="padding:3px;">Contact</a></td>
<td style="height: 16px"><img style="border:none;" alt="Find out about Abtec" src="images/information.gif"><a href="aboutus.aspx" style="padding:3px;">About Us</a></td>
<td style="height: 16px"><img style="border:none;" alt="Find out about Abtec" src="images/information.gif"><a href="supportform.aspx" style="padding:3px;">Enquiry</a></td>
<td style="height: 16px"><img style="border:none;" alt="Find out about Abtec" src="images/user.gif"><a href="careers.aspx" style="padding:3px;">Careers</a></td>
</tr>
</table>
</div>

<!-- Mini navigation end -->

</div>

<!-- Search and navigation module start -->


<!-- Search Module -->

<div>
<div style="float:left; margin-left:20px;">

<div style="height:0px;text-align: right; width:419px; background-color:lavender; background: url(images/custom_corners_topleft.gif) top left no-repeat;">

<div style="float:left;padding:3px 0px 0px 4px; height:10px; ">

<img style="border:none;" alt="Abtec Network Systems" src="images/house.gif"><a href="index.aspx" style="padding:3px;">Home</a><a><span style="color:gray;"> | </span></a><img style="border:none;" alt="Abtec Network Systems" src="images/sitemap_color.gif"><a href="sitemap.aspx" style="padding:3px;">Sitemap</a>

</div>
<form runat="server">
<div style="float:left;width:288px; margin-bottom:-23px; height:50px;border-bottom:1px solid silver; padding:3px 8px 0px 0px;background-color:;text-align:right; background: url(images/custom_corners_topright.gif) top right no-repeat;margin-right:-10px;">

<img style="border: none;" alt="Abtec Network Systems" src="images/magnify.gif"><a
style="padding: 3px;">Search</a>

<asp:TextBox ID="txtSearch" Columns="12" style="height: 17px; border: 1px solid #1c3f94;" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" PostBackUrl="~/SiteSearch.aspx" runat="server" Text="Go!" style="height: 20px; font-size: 8pt; background-color: #1c3f94; border: none; color: white;"/>


</form>
</div>

<!-- Search Module ends -->


<!-- Drop down boxes navigation -->



<div id="navig" style="">

<ul id="nav">

<li><a href="aboutus.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;">About
Us</a>

<ul>

<li><a href="accreditations.aspx" style="width: 100px; font-size:8pt;">Accreditations</a></li>

<li><a href="history.aspx" style="width: 100px; font-size: 8pt;">History</a></li>

<li><a href="partners.aspx" style="width: 100px; font-size:8pt;">Partners</a></li>

</ul>

</li>

<li><a href="services.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;"><span>Services</span></a>

<ul>

<li><a href="services.aspx#consultancy" style="width: 110px; font-size: 8pt;">Consultancy</a></li>

<li><a href="services.aspx#design" style="width: 110px; font-size: 8pt;">Design</a></li>

<li><a href="services.aspx#installation" style="width: 110px; font-size: 8pt;">Installation</a></li>

<li><a href="services.aspx#maintenance" style="width: 110px; font-size: 8pt;">Maintenance</a></li>

<li><a href="brokerage.aspx" style="width: 110px; font-size: 8pt;">Brokerage</a></li>

</ul>

<li><a href="solutions.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;"><span>Solutions</span></a>

<ul>

<li><a href="wan.aspx" style="width: 190px; font-size: 8pt;">Wide Area Networking</a></li>

<li><a href="lan.aspx" style="width: 190px; font-size: 8pt;">Local Area Networking &amp; Servers</a></li>

<li><a href="telefunky.aspx" style="width: 190px; font-size: 8pt;">Telephony</a></li>

<li><a href="security.aspx" style="width: 190px; font-size: 8pt;">Security</a></li>

<li><a href="wireless.aspx" style="width: 190px; font-size: 8pt;">Wireless</a></li>

<li><a href="smb.aspx" style="width: 190px; font-size: 8pt;">SMB</a></li>

<li><a href="ent.aspx" style="width: 190px; font-size: 8pt;">Enterprise</a></li>

</ul>

</li>

<li><a href="support.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;">Support</a>

<ul>

<li><a href="supportoptions.aspx" style="width: 110px; font-size: 8pt;">Support Options</a></li>

<li><a href="supportform.aspx" style="width: 110px; font-size: 8pt;" >Support Enquiry</a></li>

<li><a href="supportboltons.aspx" style="width: 110px; font-size: 8pt;" >Support Bolt-Ons</a></li>

</ul>

</li>

<li><a href="portfolio.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;">Portfolio</a>

<ul>

<li><a href="casestudies.aspx" style="width: 100px; font-size: 8pt;">Case Studies</a></li>

</ul>

</li>

<li><a href="news.aspx" style="font-weight: bold; background:transparent;border:0px solid silver;color:white;">News</a>

<ul>

<li><a href="newsarchive.aspx" style="width: 100px; font-size: 8pt;">Archive</a></li>

</ul>

</li>

</ul>

</div>

</div>

</div>
<!-- Drop down boxes navigation ends-->


<!-- Search and navigation module end -->



<div style="float: left; width: 565px;">

</div>



<div style="border-left: 1px solid silver; border-top: 1px solid silver;border-bottom: 1px solid silver;float: left; width: 476px; height: 169px;">

<div id="flashcontent"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">If you can see this text you need to upgrade your version of flash. Please click here to visit the Macromedia site and download the latest plugin.</a><br />

<br />

<div style="text-align: center;"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img style="border: 0px solid ; width: 100px; height: 41px;" alt="Get the latest FLASH plugin" src="images/flashbutton.gif"></a>
</div>

<script type="text/javascript">var fo = new FlashObject("images/banner1.swf", "mymovie", "476", "167", "7", "#ffffff");
fo.addParam("loop", "true");
fo.addParam("scale", "exactfit");
fo.addParam("WMODE", "opaque");
fo.write("flashcontent");
</script></div>

</div>

<div style="background: transparent none repeat scroll 0%; float: right; width: 181px; height: 80px; border-top: 1px solid silver; border-left: 1px solid silver; border-right : 1px solid silver;">

<a href="smb.aspx"><img style="border: 0px solid ; width: 181px; height: 80px;" alt="" src="images/smb1.gif"></a></div>

<div style="border: 1px solid silver; background: transparent none repeat scroll 0%; float: right; width: 181px; height: 82px; padding-top: 2px; padding-bottom: 2px;border-top: 1px solid silver; border-left: 1px solid silver;border-right : 1px solid silver;">

<a href="ent.aspx"><img title="ent" style="border: 0px solid ; width: 181px; height: 82px;" alt="" src="images/ent.gif"></a></div>

<div style="float: left; width: 212px; height: 400px; background-color:;border-bottom: 1px solid silver;border-bottom: 1px solid gray; border-left:1px solid silver;text-align:left;padding : 5px 0px 0px 10px;">

<h1>Welcome</h1>

<p>This is the website of Abtec Network Systems. We provide the complete communications solution from servers to telephony, design, installation, maintenance and support.</p>

<img src="images/arrowicon.gif" style="border:none;"><a href="aboutus.aspx" style="padding:3px;">Read more about Abtec...</a>

<h1>Accreditations</h1>

<p>Abtec has gained many accreditations and industry partners.</p>

<p><a href="accreditations.aspx"><img src="images/accredsfrontpage.gif" style="border:none;"></a></p>

<img src="images/arrowicon.gif" style="border:none;"><a href="accreditations.aspx" style="padding:3px;">View more ...</a>


</div>

<div style="float: left; width: 243px; height: 400px;background-color:;border-bottom: 1px solid silver;border-bottom: 1px solid gray; border-left:1px solid silver;text-align:left;padding : 5px 0px 0px 10px;">

<h1>What's New</h1>

<h3>FEATURE 1</h3>

Blah blah please put a really interesting feature here on something that is new with Abtec.

<h3>FEATURE 2</h3>

Blah blah please put another really interesting feature here on something that is new with Abtec.

<h1>Testimonials</h1>

<p>"Abtec are big enough to do the job, but small enough to care." - <i>Steve Lord, IT Manager- Chandlers Farm Equipment</i></p>
<p>"It has brought our entire communications system up to date, improved efficiency and reduced costs." - <i>Paul Armstrong, Financial Director - Thomas Armstrong PLC</i></p>
<img src="images/arrowicon.gif" style="border:none;"><a href="portfolio.aspx" style="padding:3px;">View more ...</a>

</div>

<div style="border-right : 1px solid silver;border-bottom: 1px solid silver;border-bottom: 1px solid gray;border-left:1px solid silver;float: left; width: 170px; height: 400px; text-align:left;padding : 5px 0px 0px 10px; text-align:left;">

<h3>CONTACT US</h3>

Abtec Network
Systems<br />

The Mill, Great Bowden Road<br />

Market Harborough<br />

Leicestershire<br />

LE16 7DE<br />

<br />

Tel: 0870 7874 500 <br />

Email: <a href="mailto:enquiry@abtecnet.com"><span style="font-weight: bold;">enquiry@abtecnet.com</span></a><br />

<a href="contact.aspx"></a><br />

<img src="images/arrowicon.gif" style="border:none;"><a href="supportform.aspx" style="padding:3px;">Make an Enquiry</a><br /><br />

<img src="images/arrowicon.gif" style="border:none;"><a href="map.aspx" style="padding:3px;">View map and directions</a>
<br /><br />

<h1>Customer of the Month</h1>

<p>Each month we showcase a customer</p>

<img src="images/salvesen.gif">

</div>



<div class="logo" style="float: right; margin-top: 5px; margin-right: 5px;"><img alt="Abtec working with BT" src="images/BT_workingwith_websmall.gif"></div>




<div class="footer">
&copy; Abtec 2006 <a href="disclaimer.aspx">Disclaimer&nbsp;</a>
</div>

</div>

</body>

</html>





-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------


Below is the code from my master page. I have removed the server.transfer code for that and just using postback url as above in the asp:button tag. This however, posts to the search page but doesnt seem to pass the search phrase and therefore the sitesearch.aspx page posts the error:

"Unable to retreive a list of documents for the specified query: The query contained only ignored words."

-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------

<%@ Master Language="VB" CodeFile="MasterPage.master.vb" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<asp:contentplaceholder id="ContentPlaceHolder3" runat="server">
</asp:contentplaceholder>
<style type="text/css">
ul {
margin: 0;
padding: 0;
list-style: none;
}
ul li {
position: relative;
float: left;
width:70px;
}
li ul {
position: absolute;
left: 0; /* Set 1px less than menu width */
top: auto;
display: none;
}
/* Styles for Menu Items */
ul li a {
display: block;
text-decoration: none;
background:white; /*; IE6 Bug */
padding: 5px;
}
/* set dropdown to default */
li:hover li a, li.over li a {
color: #777;
background-color:#fff;
}
li ul li a { padding: 2px 5px; } /* Sub Menu Styles */
li:hover ul, li.over ul { display: block;} /* The magic */
</style>

<script type="text/javascript">
// JavaScript Document
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
</script>

<script type="text/javascript" src="javascript/flashobject.js"></script>

<script language="javascript" type="text/javascript" src="javascript/datetimepicker.js">

//Date Time Picker script- by TengYong Ng of http://www.rainforestnet.com
//Script featured on JavaScript Kit (http://www.javascriptkit.com)
//For this script, visit http://www.javascriptkit.com

</script>

<link href="StyleSheet.css" rel="stylesheet" type="text/css" />
</head>
<body leftmargin="0" topmargin="0" bottommargin="10">
<form id="form1" runat="server" onclick="return form1_onclick()">
<div>
<div style="height: 100px;">
<div style="position: absolute; left: 180px; top: 40px; text-align: right; width: 419px;
background-color: lavender; background: url(images/custom_corners_topleft.gif) top left no-repeat;">
<div style="height: 40px; float: left; padding: 3px 0px 0px 4px;">
<img style="border: none;" alt="Abtec Network Systems" src="images/house.gif"><a
href="index.aspx" style="padding: 3px;">Home</a> <a><span style="color: gray;">| </span>
</a>
<img style="border: none;" alt="Abtec Network Systems" src="images/sitemap_color.gif"><a
href="sitemap.aspx" style="padding: 3px;">Sitemap</a></div>
<div style="float: left; width: 288px; height: 47px; border-bottom: 1px solid silver;
padding: 3px 8px 0px 0px; background-color: silver; text-align: right; background: url(images/custom_corners_topright.gif) top right no-repeat;
margin-right: -10px;">
<img style="border: none;" alt="Abtec Network Systems" src="images/magnify.gif"><a
style="padding: 3px;">Search</a>
<asp:TextBox ID="txtSearch" Columns="12" style="height: 17px; border: 1px solid #1c3f94;" runat="server"></asp:TextBox>
<asp:Button ID="btnSearch" PostBackUrl="~/SiteSearch.aspx" runat="server" Text="Go!" style="height: 20px; font-size: 8pt;
background-color: #1c3f94; border: none; color: white;"/>
</div>
</div>
<div style="position: absolute; left: 10px; top: 5px; text-align: left;">
<a href="index.aspx">
<img style="border: 0px solid;" alt="Abtec Network Systems" src="images/topleftabteclogo.gif"></a></div>
<div style="position: absolute; right: 10px; top: 10px; text-align: right;">
<img alt="Abtec Network Systems" src="images/commssolutionbanner.gif">
</div>
<div id="navig" style="position: absolute; left: 180px; top: 69px;">
<ul id="nav">
<li><a href="aboutus.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;">About Us</a>
<ul>
<li><a href="accreditations.aspx" style="width: 100px; font-size: 8pt;">Accreditations</a></li>
<li><a href="history.aspx" style="width: 100px; font-size: 8pt;">History</a></li>
<li><a href="partners.aspx" style="width: 100px; font-size: 8pt;">Partners</a></li>
</ul>
</li>
<li><a href="services.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;"><span>Services</span></a>
<ul>
<li><a href="services.aspx#consultancy" style="width: 110px; font-size: 8pt;">Consultancy</a></li>
<li><a href="services.aspx#design" style="width: 110px; font-size: 8pt;">Design</a></li>
<li><a href="services.aspx#installation" style="width: 110px; font-size: 8pt;">Installation</a></li>
<li><a href="services.aspx#maintenance" style="width: 110px; font-size: 8pt;">Maintenance</a></li>
<li><a href="brokerage.aspx" style="width: 110px; font-size: 8pt;">Brokerage</a></li>
</ul>
<li><a href="solutions.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;"><span>Solutions</span></a>
<ul>
<li><a href="wan.aspx" style="width: 190px; font-size: 8pt;">Wide Area Networking</a></li>
<li><a href="lan.aspx" style="width: 190px; font-size: 8pt;">Local Area Networking &amp;
Servers</a></li>
<li><a href="telefunky.aspx" style="width: 190px; font-size: 8pt;">Telephony</a></li>
<li><a href="security.aspx" style="width: 190px; font-size: 8pt;">Security</a></li>
<li><a href="wireless.aspx" style="width: 190px; font-size: 8pt;">Wireless</a></li>
<li><a href="smb.aspx" style="width: 190px; font-size: 8pt;">SMB</a></li>
<li><a href="ent.aspx" style="width: 190px; font-size: 8pt;">Enterprise</a></li>
</ul>
</li>
<li><a href="support.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;">Support</a>
<ul>
<li><a href="supportoptions.aspx" style="width: 110px; font-size: 8pt;">Support Options</a></li>
<li><a href="supportform.aspx" style="width: 110px; font-size: 8pt;">Support Enquiry</a></li>
<li><a href="supportboltons.aspx" style="width: 110px; font-size: 8pt;">Support Bolt-Ons</a></li>
</ul>
</li>
<li><a href="portfolio.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;">Portfolio</a>
<ul>
<li><a href="casestudies.aspx" style="width: 100px; font-size: 8pt;">Case Studies</a></li>
</ul>
</li>
<li><a href="news.aspx" style="font-weight: bold; background: transparent; border: 0px solid silver;
color: white;">News</a>
<ul>
<li><a href="newsarchive.aspx" style="width: 100px; font-size: 8pt;">Archive</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div class="navig1" style="left: 180px; top: 10px">
<table>
<tbody>
<tr>
<td style="height: 16px">
<img style="border: none;" alt="abtec network systems" src="images/email.gif">
<a href="contact.aspx" style="padding: 3px;">Contact</a></td>
<td style="height: 16px">
<img style="border: none;" alt="Find out about Abtec" src="images/information.gif">
</a> <a href="aboutus.aspx" style="padding: 3px;">About Us</a></td>
<td style="height: 16px">
<img style="border: none;" alt="Find out about Abtec" src="images/information.gif"></a>
<a href="supportform.aspx" style="padding: 3px;">Enquiry</a></td>
<td style="height: 16px">
<img style="border: none;" alt="Find out about Abtec" src="images/user.gif"></a>
<a href="careers.aspx" style="padding: 3px;">Careers</a></td>
</tr>
</tbody>
</table>
</div>
<div class="columnleft">
<h2>
Network Solutions</h2>
<div style="padding: 5px;">
Get the latest communication technologies with Abtec.<br>
<br>
<img style="width: 80px; height: 75px;" alt="" src="images/axxess.gif"><img style="width: 50px;
height: 67px;" alt="" src="images/serverintel.gif">
</div>
<h2>
CUSTOMER AREA</h2>
<div style="padding: 5px;">
<p>
<img src="images/arrowicon.gif" style="border: none;"><a href="login.aspx" style="padding: 3px;">Log
in to view network stats</a></p>
</div>
<h2>
Contact Us</h2>
<div style="padding: 5px;">
Abtec Network Systems<br>
The Mill, Great Bowden Road<br>
Market Harborough<br>
Leicestershire<br>
LE16 7DE<br>
<br>
Tel: 0870 7874 500
<br>
Email: <a href="mailto:enquiry@abtecnet.com"><span style="font-weight: bold;">enquiry@abtecnet.com</span></a><br>
<p>
<img src="images/arrowicon.gif" style="border: none;"><a href="contact.aspx" style="padding: 3px;">Contact
Us</a></p>
<p>
<img src="images/arrowicon.gif" style="border: none;"><a href="enquiryform.aspx"
style="padding: 3px;">Enquiry Form</a></p>
<p>
<img src="images/arrowicon.gif" style="border: none;"><a href="map.aspx" style="padding: 3px;">View
map and directions</a></p>
<div style="border: none;">
</div>
</div>
</div>
<div class="columncenter">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
<div class="columnright">
<asp:ContentPlaceHolder ID="ContentPlaceHolder2" runat="server">
</asp:ContentPlaceHolder>
</div>
<div style="width: 100%;">
</div>
<div class="logo" style="float: right; margin-top: 5px; margin-right: 5px;">
<img alt="Abtec working with BT" src="images/BT_workingwith_websmall.gif"></div>
<div class="footer">
&copy; Abtec 2006 <a href="disclaimer.aspx">Disclaimer&nbsp;</a>
</div>
</div>
</form>
</body>
</html>

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Below is an example of a content page.

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="aboutus.aspx.vb" Inherits="_Default" Title="Abtec Network Systems - About Us - Communications, LAN,
WAN, telephony, firewall and network maintenance solutions for Small
Medium and Enterprise Businesses."%>
<asp:Content ID="Content3" runat="server" ContentPlaceHolderID="ContentPlaceHolder3"><title>Abtec Network Systems - About Us - Communications, LAN,
WAN, telephony, firewall and network maintenance solutions for Small
Medium and Enterprise Businesses.</title><meta content="Communications, business telephony, pc firewall, network, maintenance, technical support, solutions, LAN, WAN, small medium business, enterprise business," name="keywords">

<meta content="Provides Communications, LAN, WAN, telephony, firewall and network maintenance Solutions for Small Medium and Enterprise Businesses. Abtec Network Systems offer network and computer technical support." name="description"></asp:content>
<asp:Content ID="Content1" runat="server" ContentPlaceHolderID="ContentPlaceHolder1"><h2 id="thecompany">The
Company</h2>

<p>Abtec provides <span style="font-weight: bold;">The
Complete Communications Solution</span>. Established in 1991,
Abtec Network Systems has built up <span style="font-weight: bold;">extensive
technology knowledge,
expertise and experience</span> in Telephone Systems, Local and
Wide Area Networks, Voice and Data Convergence, The IBM AS/400
(iSeries)
and Microsoft Windows Server Solutions.
<p>Abtec has delivered solutions
to some of the <span style="font-weight: bold;">world&rsquo;s
largest multinational corporations</span>.
Working alongside respected manufacturers such as BT, HP, Microsoft,
Cisco, Inter-Tel, 3COM and Expand, Abtec are continuously developing
partnerships and accreditations, creating a comprehensive yet flexible
portfolio of solutions. From this, Abtec can immediately source
everything
needed to <span style="font-weight: bold;">deliver
solutions to our customers</span> &ndash; for the
smallest to the largest information networks.
</p>

<h2 id="thephilosophy">The Philosophy</h2>

<p>At Abtec, we <span style="font-weight: bold;">understand
the importance of staying close to our
customers</span> and getting to know their business. As your
needs change, so
do we. That&rsquo;s why Abtec solutions are <span style="font-weight: bold;">tried, tested and
tailored </span>to your specific requirements by our in-house
Engineers. <br>

<br>

Our
networking expertise is complemented by our <span style="font-weight: bold;">proficiency in sales,
design, installation and maintenance</span>. Therefore we not
only understand
what will work for you now, but also what will work for the future. We
understand that running a business is a process of juggling many
different aspects to succeed, technology being one of them. Abtec's
experience means<span style="font-weight: bold;">:<br>

<br>

We can look after your business communications,
whilst you concentrate on the rest</span>...<br>

<br>



<p><img src="images/arrowicon.gif" style="border:none;"><a href="solutions.aspx" style="padding:3px;">View communications solutions.</a></p>

<p><img src="images/arrowicon.gif" style="border:none;"><a href="portfolio.aspx" style="padding:3px;">View customer testimonials</a></p>

</asp:Content>
<asp:Content ID="Content2" runat="server" ContentPlaceHolderID="ContentPlaceHolder2"><div id="flashcontent"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">If
you can see this text you need to upgrade your version of flash.
&nbsp;Please click here to visit the Macromedia site and download
the latest plugin.</a><br>

<br>

<div style="text-align: center;"><a href="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"><img style="border: 0px solid ; width: 100px; height: 41px;" alt="Get the latest FLASH plugin" src="images/flashbutton.gif"></a>
</div>

<script type="text/javascript">var fo = new FlashObject("images/missionstatement.swf", "mymovie", "160", "240", "7", "#FFFFFF");
fo.addParam("loop", "true");
fo.addParam("scale", "exactfit");
fo.addParam("WMODE", "opaque");
fo.write("flashcontent");
</script></div>
</asp:Content>



----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
Here is the full code for your sitesearch with the modification.


using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Search
{
/// <summary>
/// Summary description for _Default.
/// </summary>
public partial class _Default : System.Web.UI.Page
{
protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1;
protected System.Data.OleDb.OleDbDataAdapter dbAdapter;
protected System.Data.OleDb.OleDbConnection dbConnection;

protected void Page_Load(object sender, System.EventArgs e)
{
string strSearch = Request.Form["txtSearch"];

if (IsPostBack == false)
{

this.txtQuery.Text = strSearch;
this.Search();
}
}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dbAdapter = new System.Data.OleDb.OleDbDataAdapter();
this.oleDbSelectCommand1 = new System.Data.OleDb.OleDbCommand();
this.dbConnection = new System.Data.OleDb.OleDbConnection();
this.dgResultsGrid.PageIndexChanged += new System.Web.UI.WebControls.DataGridPageChangedEventHandler(this.dgResultsGrid_PageIndexChanged);
//
// dbAdapter
//
this.dbAdapter.SelectCommand = this.oleDbSelectCommand1;
//
// oleDbSelectCommand1
//
this.oleDbSelectCommand1.Connection = this.dbConnection;
//
// dbConnection
//
this.dbConnection.ConnectionString = "Provider=MSIDXS.1;Integrated Security .=\"\";Data Source=abtecwebsitesearch";

}
#endregion

protected void btnSearch_Click(object sender, System.EventArgs e)
{
this.Search();
}

private void dgResultsGrid_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
// Update the current page index.
this.dgResultsGrid.CurrentPageIndex = e.NewPageIndex;
this.Search();
}

/// <summary>
/// Gets the command string for the search.
/// <seealso cref="Search"/>
/// </summary>
private string Command
{
get
{
// Construct the base query.
string query = String.Format(@"
SELECT Rank, VPath, DocTitle, Filename, Characterization, Write
FROM SCOPE('DEEP TRAVERSAL OF ""/""')
WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config""')",
this.cboDirectory.SelectedItem.Value);

// Conditionally construct the rest of the WHERE clause.
string type = this.cboQueryType.SelectedItem.Value.ToLower();
string fmt = @" AND (CONTAINS('{0}') OR CONTAINS(DocTitle, '{0}'))";

// Get the query string and remove all semi-colons, which should stop
// attempt to run malicious SQL code.
string text = this.txtQuery.Text.Replace(";", "");
if (type == "all" || type == "any" || type == "boolean")
{
string[] words = text.Split(' ');
int len = words.Length;
for (int i = 0; i < len; i++)
{
string word = words[i];
if (type == "boolean")
if (String.Compare(word, "and", true) == 0 ||
String.Compare(word, "or", true) == 0 ||
String.Compare(word, "not", true) == 0 ||
String.Compare(word, "near", true) == 0)
continue;

words[i] = String.Format(@"""{0}""", word);
if (i < len - 1)
{
if (type == "all") words[i] += " AND";
else if (type == "any") words[i] += " OR";
}
}

query += String.Format(fmt, String.Join(" ", words));
}
else if (type == "exact")
{
query += String.Format(fmt, text);
}
else if (type == "natural")
{
query += String.Format(" AND FREETEXT('{0}')", text);
}

// Sort the results.
query += String.Format(" ORDER BY {0} {1}",
this.cboSortBy.SelectedItem.Value, this.cboSortOrder.SelectedItem.Value);

Trace.Write("Query", query);
return query;
}
}

/// <summary>
/// Perform the search.
/// </summary>
private void Search()
{
// Create a new DataSet and fill it.
try
{
this.dbAdapter.SelectCommand.CommandText = Command;
DataSet ds = new DataSet("Results");
this.dbAdapter.Fill(ds);

this.lblResultCount.ForeColor = Color.Black;
int rows = ds.Tables[0].Rows.Count;
this.lblResultCount.Text = String.Format("{0} document{1} found{2}",
rows, rows == 1 ? " was" : "s were", rows == 0 ? "." : ":");

// Bind the resulting DataSet.
this.dgResultsGrid.DataSource = ds;
this.dgResultsGrid.DataBind();

// If all was bound well, display the DataGrid.
this.dgResultsGrid.Visible = (rows > 0);
}
catch (Exception ex)
{
this.lblResultCount.ForeColor = Color.Red;
this.lblResultCount.Text = String.Format("Unable to retreive a list " +
"of documents for the specified query: {0}", ex.Message);

this.dgResultsGrid.Visible = false;
}
finally
{
this.lblResultCount.Visible = true;
}
}

/// <summary>
/// Get the appropriate title from the <see cref="DataGridItem.DataItem"/>
/// bound to the <see cref="DataGrid"/>.
/// </summary>
/// <param name="value">A <see cref="DataGridItem.DataItem"/> for the current record.</param>
/// <returns>Either the "DocTitle" or "Filename" respectively.</returns>
protected object GetTitle(object value)
{
string title = DataBinder.Eval(value, "DocTitle") as string;
if (title != null && title.Length > 0) return title;

return DataBinder.Eval(value, "Filename");
}

/// <summary>
/// Encodes the characterization since some malformed text could cause
/// the web browser to not render the remaining elements.
/// </summary>
/// <param name="value">A <see cref="DataGridItem.DataItem"/> for the current record.</param>
/// <returns>The encoded characterization.</returns>
protected string GetCharacterization(object value)
{
return Server.HtmlEncode(DataBinder.Eval(value, "Characterization") as string);
}
}
}

----------------------------------------------------------------------------
----------------------------------------------------------------------------
----------------------------------------------------------------------------
THANKS FOR ALL THE HELP!!!!! This is a very frustrating occurence!!! and I would like to learn why it is happening!

Andrew


-- modified at 11:43 Thursday 21st September, 2006

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.