473,626 Members | 3,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Highlight Text based on certain criteria

The senario is that a user fills out a form specifying some keywords they
want to search a knowledgebase for. For each article that comes back, the
words in the article that match their keywords are highlighted. (Much like
Windows Help does)

At serverside, how would I go about handling this?

--
Stephajn Craig
Nov 17 '05 #1
2 2287
I can't tell you the exact steps, but within your code-behind file, open a HTTP connection and read the HTML file you want to expose. Then write the content to the client almost 1:1 by using "Response.Write ();". Before writing the content you have to examine it and add highlighting tags to it, of course.

HTH,
Axel Dahmne

---------------------------------
"Stephajn Craig" <s.*****@NOSPAM funsunvacations .com> schrieb im Newsbeitrag news:#k******** ******@TK2MSFTN GP12.phx.gbl...
The senario is that a user fills out a form specifying some keywords they
want to search a knowledgebase for. For each article that comes back, the
words in the article that match their keywords are highlighted. (Much like
Windows Help does)

At serverside, how would I go about handling this?

--
Stephajn Craig



Nov 17 '05 #2
If you're using just plain text, it is rather simple:

- Read the whole text into a string variable,
- Search each of the words using string.indexOf( ) as much as required,
store the indices (+string length) found into a sorted array or anything.
- Go through the array in reverse order and add your tags to the string
at the appropriate places,
- Output the string using Response.Write( );

However, it becomes quite complicated if the text contains formatting. In that case I suppose you look for an appropriate control helping you in searching/editing the text portion of the data. There's an IE control providing a HTML-DOM and an XML control (MSXML) providing an XML-DOM.

Axel Dahmen
----------------------
"Stephajn Craig" <s.*****@NOSPAM funsunvacations .com> schrieb im Newsbeitrag news:ea******** ******@TK2MSFTN GP11.phx.gbl...
Would I have to do this on a word by word basis? For instance, if I split
all of the words into a giant array using a space as a delimiter, and then
loop down through the array finding a match?

And might this work if the content isn't coming from a file, but instead
from a database?

--
Stephajn Craig

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4525
by: David Morgan | last post by:
Hello I have a little function to highlight text if it exists. Function Highlight(vFind, vSearch) Dim RegEx Set RegEx = New RegExp RegEx.Pattern = vFind RegEx.IgnoreCase = True Highlight = RegEx.Replace(vSearch, "<span class=""Highlight"">" & vFind &
3
9280
by: Christophe Guillon | last post by:
Hello I would like to have a hypertext link which, when I click on it, leads to a web page where a certain word is highlighted. Depending on the link, the same target page would be displayed but with a different word highlighted. A bit like the search on google using the "cached" pages I have looked in several HTML tutorials, but I haven't found the answer...
5
18256
by: Cro | last post by:
Hello Access Developers, I'd like to know if it is possible to perform a count in an expression that defines a control source. My report is based on a query. In my report, I want a text box to display the number of times a certain value appears in a certain field (i.e. perform a ‘count'). I will be doing this for many values in many fields so do not wish to have scores of queries to build my report.
2
8551
by: Dan Schumm | last post by:
I'm relatively new to regular expressions and was looking for some help on a problem that I need to solve. Basically, given an HTML string, I need to highlight certain words within the text of the string. I had it working somewhat, but ran into problems if one of the highlighted words could also be part of an HTML tag (such as 'Table' or 'Border'). What I need is the regex to find the word, but ignore any words that fall between an HTML...
3
9547
by: Chung Leong | last post by:
Here's the rest of the tutorial I started earlier: Aside from text within a document, Indexing Service let you search on meta information stored in the files. For example, MusicArtist and MusicAlbum let you find MP3 and other music files based on the singer and album name; DocAuthor let you find Office documents created by a certain user; DocAppName let you find files of a particular program, and so on. Indexing Service uses plug-ins...
2
1412
by: -Steve- | last post by:
I have the need to change the text of certain rows to red based on the proximity of a date in one of the columns. What's the best way to go about this?
2
4606
by: SHAWTY721 | last post by:
I have a form that contains two combo boxes that are related to each other. I need to find a way to populate my text box based on the criteria of the two combo boxes so the appropriate number appears in the text box.
0
2181
by: Mel | last post by:
I have a treeview control that contains a list of filenames which I am searching. If a file in the tree matches the search criteria the entire node is expanded. Often times there are other files in that expanded node that don't match the criteria. Is there a way to highlight ALL the nodes that matched the search criteria? Example Code (Using ASP.NET 2.0, Visual Basic): Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As...
7
15042
by: sphinney | last post by:
I have a datasheet style form with textbox (MyTextBox) that has the Text Format property set to "Rich Text". It is bound to a memo field in a table. How do I change the text or highlight color of certain text in the textbox such that the formating is saved in an underlying memo field? My situation is a little different than other posts I read. Most posts show how to find and select certain text in a textbox, and then change the formating...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8701
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8502
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.