ASP.NET网站全文检索(代码部分)
2004-10-27 14:36
507 查看
前文 ASP.NET网站全文检索 主要是收集整理的一些资料,本文是使用Microsoft Indexing Service进行网站全文检索的代码部分,配置部分见这里。
ASPX页面代码如下:
<tr>
<td class="record" height="20">关 键 词:
<asp:textbox id="txtQuery" accessKey="Q" runat="server" Width="250px" MaxLength="50"></asp:textbox>
<asp:button id="btnSearch" runat="server" Text="搜索" EnableViewState="False"></asp:button></td>
</tr>
<tr>
<td height="10">查询方式:
<asp:dropdownlist id="cboQueryType" accessKey="T" runat="server" Width="250px" EnableViewState="False">
<asp:ListItem Value="All" Selected="True">包含全部的字词</asp:ListItem>
<asp:ListItem Value="Any">包含任何一个字词</asp:ListItem>
<asp:ListItem Value="Boolean">布尔表达式查询</asp:ListItem>
<asp:ListItem Value="Exact">全字匹配</asp:ListItem>
<asp:ListItem Value="Natural">自然语言查询</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td class="record" height="20">查询范围:
<asp:dropdownlist id="cboDirectory" accessKey="D" runat="server" Width="250px" EnableViewState="False">
<asp:ListItem Value="/" Selected="True">整个网站</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td class="record" height="20"><asp:label id="lblResultCount" runat="server" Font-Italic="True" visible="False" EnableViewState="False"></asp:label></td>
</tr>
<tr>
<td vAlign="top" height="210">
<asp:datagrid id="dgResultsGrid" runat="server" PageSize="15" AllowPaging="True" AutoGenerateColumns="False"
Visible="False" GridLines="None" EnableViewState="False">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="排名">
<HeaderStyle Width="40px"></HeaderStyle>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="文档信息">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<p>
<a href='<%# DataBinder.Eval(Container.DataItem, "VPath")%>' target="_blank">
</a>
<br>
<br>
-
k </i>
</p>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Visible="False"></PagerStyle>
</asp:datagrid>
</td>
</tr>
后台代码,使用VB.NET书写:
' 绑定查询结果
' 如果网页没有Title,那么使用文件名
' 取摘要
' 取文件尺寸,单位KB
Protected Function GetFileSize()Function GetFileSize(ByVal value As Object) As String
Return Convert.ToString(CInt(Convert.ToInt32(DataBinder.Eval(value, "Size")) / 1000))
End Function
界面外观如下图:
ASPX页面代码如下:
<tr>
<td class="record" height="20">关 键 词:
<asp:textbox id="txtQuery" accessKey="Q" runat="server" Width="250px" MaxLength="50"></asp:textbox>
<asp:button id="btnSearch" runat="server" Text="搜索" EnableViewState="False"></asp:button></td>
</tr>
<tr>
<td height="10">查询方式:
<asp:dropdownlist id="cboQueryType" accessKey="T" runat="server" Width="250px" EnableViewState="False">
<asp:ListItem Value="All" Selected="True">包含全部的字词</asp:ListItem>
<asp:ListItem Value="Any">包含任何一个字词</asp:ListItem>
<asp:ListItem Value="Boolean">布尔表达式查询</asp:ListItem>
<asp:ListItem Value="Exact">全字匹配</asp:ListItem>
<asp:ListItem Value="Natural">自然语言查询</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td class="record" height="20">查询范围:
<asp:dropdownlist id="cboDirectory" accessKey="D" runat="server" Width="250px" EnableViewState="False">
<asp:ListItem Value="/" Selected="True">整个网站</asp:ListItem>
</asp:dropdownlist>
</td>
</tr>
<tr>
<td class="record" height="20"><asp:label id="lblResultCount" runat="server" Font-Italic="True" visible="False" EnableViewState="False"></asp:label></td>
</tr>
<tr>
<td vAlign="top" height="210">
<asp:datagrid id="dgResultsGrid" runat="server" PageSize="15" AllowPaging="True" AutoGenerateColumns="False"
Visible="False" GridLines="None" EnableViewState="False">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
<HeaderStyle Font-Bold="True"></HeaderStyle>
<Columns>
<asp:TemplateColumn HeaderText="排名">
<HeaderStyle Width="40px"></HeaderStyle>
<ItemTemplate>
</ItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="文档信息">
<ItemStyle HorizontalAlign="Left" VerticalAlign="Top"></ItemStyle>
<ItemTemplate>
<p>
<a href='<%# DataBinder.Eval(Container.DataItem, "VPath")%>' target="_blank">
</a>
<br>
<br>
-
k </i>
</p>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<PagerStyle Visible="False"></PagerStyle>
</asp:datagrid>
</td>
</tr>
后台代码,使用VB.NET书写:
' 绑定查询结果
' 如果网页没有Title,那么使用文件名
' 取摘要
' 取文件尺寸,单位KB
Protected Function GetFileSize()Function GetFileSize(ByVal value As Object) As String
Return Convert.ToString(CInt(Convert.ToInt32(DataBinder.Eval(value, "Size")) / 1000))
End Function
界面外观如下图:
相关文章推荐
- ASP.NET网站全文检索(代码部分)
- ASP.NET网站全文检索(代码部分)
- ASP.NET网站全文检索(代码部分)
- ASP.NET网站全文检索
- ASP.NET网站全文检索
- ASP.NET网站全文检索
- asp.net中的“按需打印”(打印你需要打印的部分) 实现代码
- 不修改代码就能优化ASP.NET网站性能的一些方法
- asp.net不允许重复登陆代码(网站行)
- ASP.NET网站建设之代码分离
- asp.net网站实现接入QQ登录示例代码
- 不修改代码就能优化ASP.NET网站性能的一些方法
- 不修改代码就能优化ASP.NET网站性能的一些方法 [转]
- 不修改代码就能优化ASP.NET网站性能的一些方法
- ASP.NET网站管理系统退出 清除浏览器缓存,Session的代码
- asp.net网站设计,忘记密码功能的代码实现?
- 记录asp.net网站是什么原因导致停止运行的代码
- 一种基于自定义代码的asp.net网站首页根据IP自动跳转指定页面的方法!
- ASP.NET网站建设基本常用代码
- asp.net网站中上传文件代码