Highlight Text based on certain criteria

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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


    Stephajn Craig Guest

  2. Similar Questions and Discussions

    1. Building Query criteria dynamically based on Form inputs
      I need to dynamically build a db query based on form inputs; this such a typical thing I am hoping someone can shortcut me to a more elegant...
    2. Can't highlight text
      I have a file that we can't highlight the text. It is not locked or anything. We can select the text box, but can't edit the text. Three people...
    3. map based specular highlight?
      i've been mucking around with the different shader options and after a bit of playing and testing, it seem you can't set the specular highlight or...
    4. Automatically highlight text in a text field using a button?
      Is there anyway of automatically highlighting (select) all the text in a particular text field, say when pressing a button? If anyone can help?
    5. Different Subforms based on Query Criteria
      I am trying to create a "Workorder" form based on an equipment list and I want the subforms to be different based the "Type" field in the equipment...
  3. #2

    Default Re: Highlight Text based on certain criteria

    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.craig@NOSPAMfunsunvacations.com> schrieb im Newsbeitrag news:#kobI1LRDHA.2204@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
    >
    >
    Axel Dahmen Guest

  4. #3

    Default Re: Highlight Text based on certain criteria

    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.craig@NOSPAMfunsunvacations.com> schrieb im Newsbeitrag news:eag7vqNRDHA.1580@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

    Axel Dahmen Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139