国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁(yè) > 學(xué)院 > 開(kāi)發(fā)設(shè)計(jì) > 正文

使用asp.net進(jìn)行多關(guān)鍵字查詢的例子

2019-11-18 17:20:18
字體:
來(lái)源:轉(zhuǎn)載
供稿:網(wǎng)友

下面的代碼演示了如何對(duì)一段文本進(jìn)行多關(guān)鍵字查詢并高亮顯示,給自己做為一個(gè)小tip保留下
<%@ Page Language="C#" Debug="False" Strict="True" Explicit="True" Buffer="True"%>
<%@ Import Namespace="System" %>
<html>
<head>
<title></title>
</head>
<style type="text/CSS">
.highlight {}{text-decoration:none; font-weight:bold; color:white; background:blue;}
</style>
<body bgcolor="#FFFFFF" topmargin="0"  onLoad="document.forms[0].keyWords.focus();">
<script language="C#" runat="server">
void Page_Load(Object Source, EventArgs E)
{
LabelTxt.Text = "Give the PRoper respect to hand-coding.You should both respect and loathe handwritten code. You should

respect it because there are often special cases integrated into code that are overlooked with a cursory inspection. When

replacing code you’ve written by hand, you need to make sure you have the special cases accounted for. You should loathe

hand-code because engineering time is extremely valuable, and to waste it on repetitive tasks is nearly criminal. The goal

of your generator should always be to optimize the organization’s most valuable assets.the creativity and enthusiasm of

the engineering team.";
}
public string Highlight(string Search_Str, string InputTxt)
{
    Regex RegExp = new Regex(Search_Str.Replace(" ", "|").Trim(), RegexOptions.IgnoreCase);
    return RegExp.Replace(InputTxt, new MatchEvaluator(ReplaceKeyWords));
    RegExp = null;
}
public string ReplaceKeyWords(Match m)
{
    return "<span class=highlight>" + m.Value + "</span>";
}
public void ButtonClick(Object sernder,System.EventArgs e )
{
    LabelTxt.Text = Highlight(keywords.Text, LabelTxt.Text);
}
</script>
<H3></H3><BR>
<form runat="server" method="post">
<asp:TextBox id="keywords" runat="server"/>
<asp:Button id="button" Text="Submit" runat="server" OnClick="ButtonClick"/><br><br>
<asp:Label id="LabelTxt" runat="server"/>
</form>
</body>
</html>


發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 托里县| 长岛县| 汉源县| 三明市| 禹州市| 渭源县| 鹤壁市| 仪陇县| 沙坪坝区| 承德市| 肥西县| 资兴市| 莱西市| 嵊州市| 修文县| 江川县| 池州市| 临朐县| 筠连县| 龙口市| 尼木县| 上犹县| 隆德县| 清丰县| 子洲县| 台南市| 于田县| 自贡市| 高台县| 民和| 虹口区| 渭南市| 清原| 林西县| 光山县| 左权县| 西和县| 自贡市| 陇川县| 进贤县| 土默特左旗|