|
|
|
|
Using Index Server for ASP.NET Site Search
By
sushilsaini January 23, 2004
This projects highlights how to add search facility to your ASP.NET page using ADO.NET to browse index server search catalogs.
|
|
Technologies:
.NET 1.0/1.1, ASP.NET 1.0,Visual C# .NET |
|
Total downloads : |
298 |
|
Total page views : |
32038 |
|
Rating : |
|
4/5 |
|
This article has been rated : |
2 times |
|
|
|
|
Download
Files:
|
|
|
|
|
|
|
|
|
|
Similar ArticlesMost ReadTop RatedLatest
|
|
Related EbooksTop Videos
|
|
|
Description
|
|
LINQ for Visual C# 2005 is a short yet comprehensive guide to the major features of LINQ. It thoroughly covers LINQ to Objects, LINQ to SQL, LINQ to DataSet, and LINQ to XML.
|
|
|
|
|
|
|
|
|
|
|
|
|
Description
This is a sample project made to help ASP.net developers. This projects highlights how to add search facility to your asp.net page using ADO.net to browse index server search catalogs. To be able to understand this , developer should have knowledge of using ADO.net to show the data on the Asp.net Page.
Introduction
This code is developed to enable search facilities to ASP.net applications. This is a easy to use as only with few lines of code you will be able provide dynamism to your applications. It works like accessing a query from database. Before starting this project , you must create a catalog using the Index Server. To read more details how to create and configure catalogs
Table Format
| Heading |
Heading |
| using Index Server Search in ASP.net |
This is a sample project made to help ASP.net developers. This projects highlights how to add search facility to your asp.net page using ADO.net to browse index server search catalogs. To be able to understand this , developer should have knowlege of using ADO.net to show the data on the Asp.net Page. |
Create Catalog : To create a catalog
- In the MMC, select Index Server.
- From the Action menu, select Stop.
You must stop the Content Index service before you can add a catalog.
- From the Action menu, select Create New and then Catalog.
- In the Add Catalog dialog box, type the name of the catalog.
- Click the Browse button and select a directory where you want this new catalog to be located.
- When you have selected the catalog location, click the OK button.
- With Index Server selected, from the Action menu, select Start.
Restarting Index Server makes the new catalog available for the indexing process.
Note : Before you can add a new catalog, you must stop Index Server. After you create a new catalog, you must restart Index Server to bring the new catalog online. But before bringing it online, you may want to add directories and modify catalog properties.
Summary using catalog in asp.net
This project is development using following packages in the ASP.net Application with Csharp.
using System.Data; using System.Data.OleDb;
ASPX page contains one textbox , Button and label on the page
< form id="search" method="post" runat="server"> <TABLE id="Table3" cellSpacing="1" cellPadding="1" width="95%" align="right" border="0"> <TR> <TD> <P> </P> <P> <asp:Label id="Label1" runat="server">Search Site</asp:Label> <asp:TextBox id="txtSearch" runat="server"></asp:TextBox> <asp:Button id="btnSearch" runat="server" Text="Search"></asp:Button><BR> <BR> <asp:Label id="lbl" runat="server"></asp:Label></P> </TD> </TR> </TABLE> </form>
protected System.Web.UI.WebControls.TextBox txtSearch; protected System.Web.UI.WebControls.Label Label1; protected System.Web.UI.WebControls.Button btnSearch; protected System.Web.UI.WebControls.Label lbl; public int cnt; /// <SUMMARY> /// On the click of button, search for the keyword in the index catalog , and show the matching result on the page /// </SUMMARY> /// <PARAM name="sender"></PARAM> /// <PARAM name="e"></PARAM> private void btnSearch_Click(object sender, System.EventArgs e) { // connecting string for connecting index server, In this provider name is MSIDXS ; DataSource is name of the catalog name in the index server. // create a connection object and command object, to connect the Index Server System.Data.OleDb.OleDbConnection odbSearch = new System.Data.OleDb.OleDbConnection(); System.Data.OleDb.OleDbCommand cmdSearch = new System.Data.OleDb.OleDbCommand(); //assign the connecting string to the oledb connection object , replace Catalog Name with the name of index catalog created earlier odbSearch.ConnectionString = "Provider=\"MSIDXS\";Data Source=\"[Catalog name]\";"; //assign connection to command object cmdSearch cmdSearch.Connection = odbSearch; //Query to search a free text string in the catalog in the contents of the indexed documents in the catalog try { // Make freetext search in the contents and retreive document titles , path , rank from the index catalog cmdSearch.CommandText = "select doctitle, filename, vpath, rank, characterization from scope() where FREETEXT(Contents, '"+txtSearch.Text +"') and filename <> 'search.aspx' order by rank desc "; odbSearch.Open(); try { OleDbDataReader rdrSearch = cmdSearch.ExecuteReader(); //dg1.DataSource=rdrSearch; //dg1.DataBind(); cnt=1; lbl.Text=""; // your databinding or display code here while( rdrSearch.Read()) { // Call method get pagelink to write process and show the valid link on the page , here we have used getpagelink to show the file name searched getpagelink(rdrSearch[1].ToString()); } } catch(Exception ex) { lbl.Text=ex.Message ; } odbSearch.Close(); } catch( SqlException ex) { lbl.Text=ex.Message.ToString(); odbSearch.Close(); } } /// <SUMMARY> /// This function creates the link of the searched document in the predefined template. /// </SUMMARY> /// <PARAM name="srcfile">This Function is </PARAM> public void getpagelink(string srcfile) { string temp= (cnt).ToString() +".) " + srcfile; }
To customize your pages , you can put several Headers and other HTML Tags to make it familiar to your pages, In case you have already fixed your templates you can make a user control instead of making a ASPX page and then add User control to any of webforms and load them, using this technique.
To test this page type keyword in the text box and click the button given on the page and wait for the page response.
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
C# Consulting is founded in 2002 by the founders of C# Corner. Unlike a traditional
consulting company, our consultants are well-known experts in .NET and many of them
are MVPs, authors, and trainers. We specialize in Microsoft .NET development and
utilize Agile Development and Extreme Programming practices to provide fast pace
quick turnaround results. Our software development model is a mix of Agile Development,
traditional SDLC, and Waterfall models.
|
|
Click here to learn more about C# Consulting. |
|
|
|
|
|
|
|
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon.
Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees.
As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
|
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
|
Boost the performance of your .NET applications
“ANTS Profiler took us straight to the specific areas of our code which were the cause of our performance issues." Terry Phillips, Sr. Developer, Harley-Davidson Dealer Systems. Download your free trial of ANTS Profiler.
|
Go.NET
Build custom interactive diagrams, network, workflow editors, flowcharts, or software design tools. Includes many predefined kinds of nodes, links, and basic shapes. Supports layers, scrolling, zooming, selection, drag-and-drop, clipboard, in-place editing, tooltips, grids, printing, overview window, palette. 100% implemented in C# as a managed .NET Control. Document/View/Tool architecture with many properties&events. Optional automatic layout.
|
Dundas Software
Dundas Chart for .NET is the most advanced .NET charting package available today. With an extremely complete feature set, elegant architecture and easy implementation, Dundas Chart can quickly add advanced Charting functionality to enhance and transform ASP.NET and Windows Forms applications. Whether you are implementing charting into internal projects, or building applications for clients, Dundas Chart offers advanced technology and advanced results to get the most out of data.
|
|
|
|
|
|
|
|
|
Download
Files:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|