Click here to Skip to main content
15,881,381 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi How to highlight the search word with change the back color or font color ?In button click event i am search the word and load the paragraph containing search word in label.At the time of loading in label i need to highlight the search word.



pls reply me asap

Reagrds
Aravind
Posted
Comments
ridoy 12-Aug-13 9:38am    
have you tried anything?

1 solution

try this function:-
VB
Function Highlight(vFind, vSearch)
    Dim RegEx
    Set RegEx = New RegExp
    RegEx.Pattern = vFind
    RegEx.IgnoreCase = True
    Highlight = RegEx.Replace(vSearch, "<span class=""Highlight"">" & vFind &"</span>")
    Set RegEx = Nothing
End Function


This is not about case sensitive searching, this is about showing the actual
match rather than what was being searched for. Hope that makes sense.

For example:
Response.Write Highlight("something", "Have you seen Something About
Mary?")

Gives:
Something (with highlighted).

If you want to go with jquery then see below link:-
http://hugoware.net/blog/more-jquery-magic-search-highlighting[^]
Demo[^]
 
Share this answer
 
v2
Comments
Aravindba 12-Aug-13 9:51am    
Hai
Thank u for ur reply,i paste this code in vb,Dim RegEx gives error,i am ask in asp.net(Website)
TrushnaK 13-Aug-13 1:54am    
See your que. you tag it with vb.net.
if you want that in asp then see that links i already sent.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900