网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP.NET技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.关于Asp.net页面Page_Load被执行.
.ASP.NET 2.0 AJAX中Webservice调.
.ASP.NET 2.0中的输出缓存.
.关于2.0 中的用户控件编程使用.
.在ASP.net中使用TinyMCE的小tip-.
.我的aspx为什么无法显示中文.
.AspNetForums的数据层概述.
.Asp.net给站点某目录增加Aspnet用.
.用ASP.NET 2.0 FormView控件控制.
.在ASP.NET应用程序中捕捉身份验证.
.web.config配置文件示例.
.ASP.NET控件开发之"代码紧凑原则".
.将以前写的SQL2分查找法通用分页.
.DataGrid的多行提交.
.asp.net身份验证(登录控件),基于.
.在.NET 2.0 中发送Email.
..net发送邮件的一些技巧.
.URL重写可删节日期模式---正则表.
.ASP.NET设计中的性能优化问题.
.修改asp.net2.0内置成员管理中的.

使用asp.net进行多关键字查询的例子

发表日期:2006-3-23


下面的代码演示了如何对一段文本进行多关键字查询并高亮显示,给自己做为一个小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>

上一篇:实现.NET应用程序的自动更新 人气:6723
下一篇:ASP.NET无限分类 人气:6195
浏览全部asp.net的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐