highlight certain text in a textbox in asp.net

2.9k views Asked by At

I need TextBox in asp.net to highlight some text when certain event occurs while text is being typed (as in Microsoft Word spell check feature).

I have been using freetextbox, it highlights the text on a button click but not automatically.

How to do that?
Should I use another control?

2

There are 2 answers

0
Lucky Lefty On

You can use jquery and check for each keypress, when your word combination is met you can use css to highlight text.

function is .keypress() - more on keypress

0
Pratik Singhal On

You can use a RichTextBox for doing it.
With RichTextBox, you can color or highligh single lines or words.

    // select characters from index 0 to 9
     richTextBox1.Select(0, 10);

   //will color the selected text.
   richTextBox1.SelectionColor = Color.Green;    

Check this link for a tutorial.