473,396 Members | 1,772 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 2277
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.*****@NOSPAMfunsunvacations.com> schrieb im Newsbeitrag news:#k**************@TK2MSFTNGP12.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.*****@NOSPAMfunsunvacations.com> schrieb im Newsbeitrag news:ea**************@TK2MSFTNGP11.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
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 =...
3
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...
5
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...
2
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...
3
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...
2
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
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...
0
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...
7
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.