views:

109

answers:

1

I am creating a web chat facility in visual studio 2008 using Visual Basic,I want to be able to highlight certain keywords that are sent and received to each user, can someone please tell me how I can do this? Thanks in advance

A: 

If you're creating an Asp.net app. with VB.Net then here's something you can do: 1. On your page you may have a textbox (where the user types the text for chat) and there may be a "Send" button that postbacks the page. 2. On click of "Send", pick the text from the text box and search for your keyword, you may do something like this: if(txtChat.Text.Contains(keyword_string)) { //Highlight the text --- } else { //Send logic }

You can put the if/else in a loop if you wish to scan multiple values from the db. As for selecting the text, it's a tricky part and I myself haven't found a simple way to select partial text in an Asp.net textbox. Here's are a couple of links discussing alternate ways to perform this:

http://forums.asp.net/t/1520680.aspx

http://bytes.com/topic/javascript/answers/167174-highlighting-part-text-text-box

If it's possible you can show the words separately in a label beneath the textbox.

Sidharth Panwar