Show search results in real-time as you type

I am currently developing a SharePoint 2007 web part using Visual Studio. The main goal of this web part is to search a SharePoint list and present the results to the user.

My objective is to have the results displayed automatically once the user finishes typing, without the need for clicking a button.

I believe that a mix of the text_changed event and onkeydown javascript could help achieve this functionality.

I would appreciate any suggestions or thoughts on this matter.

By the way, it's worth mentioning that the sharepoint site I'm working with is "Ajax-enabled".

Thank you!

Answer №1

If you're looking for a solution, I recommend utilizing jquery and the keyup event:

$("input#txtid").keyup(function () {
                if (this.value.length < 8)
                    return false;

                $.get("ServiceUrl", { arg: this.value }, function (result) { $("#output").html(result); });

            });

Answer №2

One of the simplest methods to manage the UI aspect is by employing the AjaxToolkit AutoCompleteExtender set up Optimizing Your Website Using AutoCompleteExtender. After implementing this, the only task left is determining the search process within the web service.

Answer №3

To tackle this task, I implemented the use of an UpdatePanel within my webpart. Added within the UpdatePanel were a Button (more details on this later) and a TextBox.

In addition, I incorporated a JavaScript class responsible for managing the logic behind submitting a query once the user had paused while typing their query. This class included an event handler for the onkeyup event, which was linked to the TextBox:

t.Attributes.Add("onkeyup", "javascript:oSearchClass.KeyUpEventHandler(event);");

I leveraged the functionalities of setTimeout and clearTimeout to dictate when the class should invoke the SubmitQuery function.

Upon calling SubmitQuery(), the TextBox would transition into read-only mode (preventing users from making any further inputs during the querying process) before simulating a click action on the button through click(). By utilizing a standard Button, the Button.click event could be managed like usual in order to re-query the list and exhibit the outcomes.

If showcasing the button to users is not desirable, it can be encapsulated within a hidden WebControl such as span.

Answer №4

Check out this example showcasing how 'search as you type' functionality can be incorporated into the standard SharePoint search box.

Implementing ‘Search As You Type’ feature in SharePoint using a custom solution.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Revamping JSON structure by identifying id references

I recently attempted to update the city name within the JSON object provided below. "City":[ { "Name":"Delhi", "id":"c5d58bef-f1c2-4b7c-a6d7-f64df12321bd", "Towns":[ ...

Difficulty arises when trying to extract specific information from an ajax response using the jQuery.filter

The code snippet below seems to be causing some trouble. It's supposed to filter HTML content that includes a div with the class "filtered_entries_box", but it's not working as expected. $.ajax({ "url" : "start.php", "type" : "POST", ...

Nomenclature in ASP.NET MVC routing, diverging from conventional controller names

Can someone help me with obtaining a URL to edit friends on my ASP.NET MVC website in the following format: site.com/friend{x}/edit Here, {x} represents the friend's ID. I am looking for guidance on how to properly set up ActionLinks, Controller na ...

Tips for managing this JavaScript JSON array

Here is an example of a JSON array: var data = { name: 'Mike', level: 1, children: [ { name: 'Susan', level: 2, }, { name: 'Jake', level: 2 }, { name: 'Roy', level: 2 }, ...

Tips for defining boundaries for position absolute elements using JavaScript

Fiddle. I am in the process of developing a chat/mail application with a resizable menu similar to the Google Hangouts desktop app. When resizing the brown content pane at a normal speed, you can observe that the boundaries are functioning as intended. My ...

Effortlessly Display or Conceal Numerous Table Columns Using jQuery

I have a small table where I want to hide certain details with a basic button... for instance, table { border-collapse: collapse; } th, td { border: 1px solid gray; padding: 5px 10px; } <button>Show/Hide Details</button> <table> ...

What could be causing the video not to display in landscape mode on the iPad Pro?

I'm having an issue with a standard HTML5 <video> on my website. The videos are working fine on most devices, however there is a problem specifically with the iPad Pro in landscape orientation. It seems to work properly in portrait orientation ...

Dealing with errors in Express.js within the service or controller layers

Currently, I am developing an Express.js application with a distinct controller layer and service layer. Below you can find the code snippet I have implemented so far: user.service.js exports.registerUser = async function (email, password) { const hash ...

Exploring Reflection through an XPath-style Query

In my class tree, I have multiple objects organized in a hierarchy. For example, I may have a Container object that contains 3 SubContainer objects, each of which can hold any number of Item objects. I am wondering if there is a way to use a reflection-ba ...

Using async/await in a POST handler within Express.js

My goal is to invoke an async function within a POST handler. The async function I'm trying to call looks like this (the code is functional): const seaport = require("./seaport.js"); // This function creates a fixed price sell order (FPSO) ...

Creating a feature in Angular JS that allows for each item in a list to be toggled individually

Looking for a more efficient way to toggle individual buttons without updating all at once? Check out this basic example where each button toggles independently by using ng-click="selected = !selected". Instead of updating all buttons at once, you can achi ...

Can a dynamic field name be incorporated into a JavaScript Object?

My goal is to dynamically add a field name and update the value based on that. In my situation, the eventType can have 4 types: delivery, send, open, click. However, when I implement this code, I am only getting the eventType as a string. const event = J ...

Uncover the reason behind the application's crash with Titanium

If we encounter non-crashing errors, utilizing LogCatcher can help by pinpointing which Javascript code is causing the issue. However, in the event of a crash, there's no time for logging Javascript errors. In such cases, integrating tools like ARCA ...

As time passes, the performance of IIS 10 on Windows Server 2016 gradually declines

We are currently experiencing an issue with our production server running on IIS 10 (Windows Server 2016). The response time of an HTTP Request seems to slow down after a period of time. Initially, we thought the problem might be related to ASP.NET Server ...

What is the best way to retrieve a particular field from a Firestore Document using JavaScript?

Within my Firestore database, I have a structure of users that looks like this: The rules set up for this database are as follows: match /users/{userID} { match /public { allow read: if request.auth != null; } match /private/ ...

What causes my useEffect hook to trigger twice in React?

I'm currently utilizing @preact/signals-react in my react project for integration purposes. Encountered a challenge that requires resolution. Interestingly, I discovered that by removing import { signal } from '@preact/signals-react', the ...

Only submit the form if all files are selected to prevent any missing files from being uploaded

I am currently utilizing the Vue.js framework along with Axios. Within my HTML page, I have incorporated two separate input fields for selecting an image. Additionally, there is a form present on the page. It's important to note that these inputs and ...

How come defining the state using setTimeout does not display the accurate properties of a child component?

Presented here is a component designed to render a list of items and include an input for filtering. If no items are present or if the items are still loading, a message should be displayed. import { useState } from "react"; export const List = ...

NGINX keeps returning 404 errors and refuses to forward requests to fastcgi-mono-server4

Working on setting up an ASP.Net application skeleton on Ubuntu. I have installed all the necessary applications, but I am facing issues serving index.html or index.aspx using Nginx. Every time I try to run it through Nginx, I receive a 404 error. The mon ...

Advancement in the Web API Controller procedure

I am currently working on an ASP.NET web form that allows users to select a mailing list and send emails to all members of the list by clicking the Send button. When the user clicks the button, I trigger an Ajax call to an ASP.NET Web API method which then ...