开发者

how to implement a site search in ASP.NET?

开发者 https://www.devze.com 2022-12-25 03:52 出处:网络
I am a noob in ASP.NET and building a website currently... I want the 开发者_运维技巧site to have a search feature.. How can I add this to my site? Is there a good tutorial out there ?Why not use Goog

I am a noob in ASP.NET and building a website currently... I want the 开发者_运维技巧site to have a search feature.. How can I add this to my site? Is there a good tutorial out there ?


Why not use Google, of course! This is the website standard for searching. : )

http://www.google.com/cse/

If you mean that you want to search your database and not your website, then usually people do a SQL query with some kind of result display - gridview (fast & easy!), or repeater.


Well, to have a search function you first need something to search in (database, hash table, heap, etc.). I assume that in this case you'll be using a database.

For a basic search function to search for a string in, say, a table of articles you could just use the following SQL statement:

SELECT * FROM `Articles` WHERE `Text` LIKE '%<search string here>%'

The '%' character is the SQL wildcard, so will match the search string wherever it's found: %hell% will match "Hello world" and "shell", etc.

That's a pretty crude way of doing it, so search around for some articles on the subject and you should be able to find some more sophisticated methods.


different ways to do it

1 : Dynamic data search within your application- You will have a search page and when user submits a search query, you will build a SELECT query using that and search in apppropriate tables ans show the results from the datasource returned from executing your select query

2 : Static page search - If you have a lot of static pages in your website,you can use this.You need to enable IIS indexing .you have to create a catalog for your site.IIS will do the rest.You need to use the code to read result from IIS index.(The code is not so big.Only few lines.Get it from google)

3 : Add Google search : You can add the google search widget to your website


Try this: Asp net with .net LUCENE or this : Also with dotnet lucene

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号