中国站长下载-为中国站长提供最好最全的建站资源! 首 页发布资源有事留言繁體中文
设为首页
加入收藏
联系我们
 
您当前的位置:中国站长下载 -> 文章中心 -> 网页编程 -> .NET编程 -> 文章内容  虚拟主机 域名注册 退出登录 用户管理
栏目导航
· ASP编程 · .NET编程
· PHP编程 · JSP编程
· CGI 专区
热门文章
· sndvol32 - sndvol3...
· [组图] FLASH:《大话李白》...
· 个人网站到底能赚多...
· [图文] Rundll.exe是病毒吗...
· [组图] Flash:制作MV
· 价值12万元的网站SE...
· 网站创业者,你需要...
· 一个成功的网站设计...
· [图文] FLASH:韩国导航条解...
· 中国网站的赚钱模式...
相关文章
· 一个oracle+PHP的查...
· 使用ASP.NET开发移动...
· 使用ASP.NET中的一点...
· 使用ASP.NET程序来管...
· [组图] 使用ASP.NET 2.0中的...
· [组图] 使用ASP.NET 2.0中的...
· 使用asp.net2.0中的...
· 使用asp.net2.0中的...
· 使用asp.net2.0中的...
· 使用ASP.NET Atlas ...
使用asp.net进行多关键字查询的例子
作者:不详  来源:不详  发布时间:2006-8-14 8:50:19  发布人:chinazhan

 减小字体 增大字体

     下面的代码演示了如何对一段文本进行多关键字查询并高亮显示,给自己做为一个小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>
  
  
    做人要厚道,请注明转自chinazhan中国站长(www.ChinaZhan.com)。

 
[] [返回上一页] [打 印] [收 藏]
∷相关文章评论∷    (评论内容只代表网友观点,与本站立场无关!) [更多评论...]
中国站长下载
中国站长下载

本页只接受PR>=4 IT类站点连接,申请连接,谢谢您们的支持!希望我们的下载站能够真正帮到中国的站长们!
关于本站 - 网站帮助 - 广告合作 - 下载声明 - 友情连接 - 网站地图
Copyright © 2005-2006 ChinaZhan.Net. All Rights Reserved .