How to Create Search Functionality in ASP.NET Website

How to Create Search Functionality in ASP.NET Website

As your site grows in pages, so does the time required for visitors to locate specific information on it. While it’s obvious to most the benefits of extending a site with search functionality, the ease in which this could be done may not be. Search box is an important thing for a website, for example is in an e-commerce site. An effective site search function on an e-commerce site has a number of potential benefits. Customers are accustomed to finding results quickly and (mainly) accurately from search engines, and will expect a similar experience on e-commerce sites. On e-commerce sites, up to 30% of visitors will use the site search box, and each of these users is showing a possible intent to purchase by entering product names or codes.

cheap-asp-search

In this article we will be creating simple search functionality in ASP.NET. Once the user searches for information, we are going to query our DataBase using Entity Framework and display the results as links in the Client Template of RadSearchBox. The control will be populated with data via Web Service, where the returned data will be structured.

The DataBase

For the sake of the example, we are going to create a simple Table (ControlsTable) adding few columns: ControlID, ControlName, ControlContents and SectionName.

Querying the DataBase Using ASP.NET Entity Framework

ASP.NET Entity Framework is an Object/Relational Mapping (O/RM) framework, which provides an automated mechanism for accessing and storing the data in the database. It provides the ability for the developers to retrieve and manipulate data as strongly typed objects using C# or VB.Net.

Each time the user types a character in the input of the control a callback is triggered to the WebService and the underlying database is requested with the above query. The retrieved entries from the database would be the ones, which contain the value that was entered in the input.

Displaying the Results

In order to provide RadSearchBox with the needed, we have to manage the returned data source in the WebService in the following manner:

Then you could easily configure the ClientTemplate of ASP.NET SearchBox control, in order to evaluate the structured data:

User Experience

At the end, what we’ve achieved is quite flexible search functionality, using a WebService and ASP.NET Entity Framework, which serves out the result in a user-friendly manner.

search_animation

Cheap ASP.NET 4.5 Hosting Recommendation

  1. Build Your ASP.NET Website
    Use ASPHostPortal.com‘s website building tools to get that special, customized look for your website. A nifty wizard will walk you through the process.
  2. All-inclusive Prices Unbeatable Value
    Other companies promise cheap hosting, but then charge extra for setup fees, higher renewal rates, or promotional services. With ASPHostPortal.com, the listed price is the number you’ll pay, and you can expect a fully loaded, comprehensive suite of web services.
  3. Fast and Secure Server
    Their powerful servers are especially optimized and ensure the best ASP.NET 4.5 performance. They have best data centers on three continent and unique account isolation for security.
  4. Easy to Use and Manage
    ASPHostPortal.com webspace explorer lets you manage your website files with a browser. A control panel lets you set up and control your server functions with ease.
[stextbox id=”asp_net_hosting” caption=”ASPHostPortal.com is Microsoft No #1 Recommended Windows Hosting Partner”]ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for the ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2012, .NET 4.5.2/ASP.NET 4.5.1, ASP.NET MVC 6.0/5.2, Silverlight 5 and Visual Studio Lightswitch. Click here for more information[/stextbox]

Anjali Punjab

Anjali Punjab is a freelance writer, blogger, and ghostwriter who develops high-quality content for businesses. She is also a HubSpot Inbound Marketing Certified and Google Analytics Qualified Professional.

You may also like...

Popular Posts