|
|
|
|
|
|
|
Page Views :
|
41296
|
|
Downloads :
|
596
|
|
Rating :
|
Rate it
|
|
Level :
|
Beginner
|
|
|
|
|
Download
Files:
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
Comment Request!
Thank you for reading this post. Please post your feedback, question, or comments about this post
Here.
|
|
|
|
|
Login
to add your contents and source code to this article
|
|
|
|
|
|
|
Contents added by
Robert
on
May 27, 2010
|
|
|
|
I am trying to exclude filename types .pdf and .doc not shown in your article
Here
is my syntax, can you shed some light on this?
string
query = String.Format(@" SELECT Rank, VPath, DocTitle, Filename,
Characterization, Write, ilAgency, ilCountryName, ilSummary,
idcAttachmentSize FROM SCOPE('DEEP TRAVERSAL OF ""{0}""')
WHERE NOT CONTAINS(VPath, '""_vti_"" OR "".config"" OR
""search_excluded""')", this.cboDirectory.SelectedItem.Value);
Rob
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
|
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites – Click Here!
|
|
|
|
|
|
|
|
|
|
|
|
|