asp.net| keyword
The following code shows how to query and highlight a piece of text in multiple keywords, and give yourself a tip to keep
<%@ Page language= "C #" debug= "False" strict= "true" explicit= "true" buffer= "true"%>
<%@ Import namespace= "System"%>
<title></title>
<style type= "Text/css" >
. highlight {}{text-decoration:none; font-weight:bold; color:white; background:blue;}
</style>
<body bgcolor= "#FFFFFF" topmargin= "0" >
<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 into the code that integrated are with a overlooked cursory. When
Replacing code you ' ve written by hand, your need to make sure your have the special cases for. You should loathe
Hand-code because engineering is extremely valuable, and to waste the it on repetitive the tasks is nearly criminal. The goal
of your generator should always is 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"/><br><br>
<asp:label id= "Labeltxt" runat= "Server"/>
</form>
</body>