如何突出asp.net中的搜索词? [英] How to highlight the search word in asp.net ?

查看:84
本文介绍了如何突出asp.net中的搜索词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi
如何通过更改背面颜色或字体颜色来突出显示搜索词?在按钮单击事件中,我搜索单词并加载包含标签中搜索词的段落。在标签i中加载的时间需要突出显示搜索词。







请尽快回复我



Reagrds

Aravind

解决方案

尝试此功能: -

< pre lang =vb> 功能突出显示(vFind,vSearch)
Dim RegEx
设置 RegEx = RegExp
RegEx.Pattern = vFind
RegEx。 IgnoreCase = True
突出显示= RegEx.Replace(vSearch, < span class =突出显示>& vFind& < / span>
设置 RegEx = 无/ span>
结束 功能





这不是关于区分大小写的搜索,这是关于显示实际的

匹配而不是搜索的内容。希望这是有道理的。



例如:

Response.Write突出显示(某事,你见过的东西吗? >
玛丽?)



给:

东西(突出显示)。



如果您想使用jquery,请参阅以下链接: -

http://hugoware.net/blog/more-jquery-magic-search-highlighting [ ^ ]

演示 [ ^


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

解决方案

try this function:-

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[^]


这篇关于如何突出asp.net中的搜索词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆