Highlight Text based on certain criteria

Discussion in 'ASP .Net' started by Stephajn Craig, Jul 7, 2003.

  1. 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
    Stephajn Craig, Jul 7, 2003
    #1
    1. Advertising

  2. Stephajn Craig

    Axel Dahmen Guest

    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" <> schrieb im Newsbeitrag news:#...
    > 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
    >
    >
    Axel Dahmen, Jul 7, 2003
    #2
    1. Advertising

  3. Stephajn Craig

    Axel Dahmen Guest

    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" <> schrieb im Newsbeitrag news:...
    > 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
    Axel Dahmen, Jul 8, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?U2NvdHQgYXQgQ2VkYXIgQ3JlZWs=?=

    Grid to count records meeting certain criteria (region)

    =?Utf-8?B?U2NvdHQgYXQgQ2VkYXIgQ3JlZWs=?=, Feb 9, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    351
    =?Utf-8?B?U2NvdHQgYXQgQ2VkYXIgQ3JlZWs=?=
    Feb 9, 2006
  2. -Steve-

    GridView Highlight Certain Rows

    -Steve-, Sep 12, 2007, in forum: ASP .Net
    Replies:
    2
    Views:
    427
    marss
    Sep 12, 2007
  3. Chris Davoli

    Highlight linkbutton in gridview for a certain row

    Chris Davoli, Apr 27, 2007, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    233
    Chris Davoli
    Apr 27, 2007
  4. Replies:
    3
    Views:
    108
    Tad McClellan
    Jun 8, 2006
  5. Cory Mottice
    Replies:
    2
    Views:
    128
    Dave Angel
    Sep 12, 2013
Loading...

Share This Page