📄 newssearch.aspx
字号:
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.OleDb"%>
<%@ Register TagPrefix="mynews" TagName="top" src="ascx/top.ascx"%>
<%@ Register TagPrefix="mynews" TagName="special" src="ascx/newslist.ascx"%>
<%@ Register TagPrefix="mynews" TagName="footer" src="ascx/footer.ascx"%>
<script language="VB" runat="server">
Dim sql as string
Dim myConn as OleDbConnection
Dim myCmd as OleDbCommand
Function getdataview(ByVal sql As String, ByVal strtable As String) As DataView
Dim myDataAdapter As OleDbDataAdapter
Dim myDataSet As DataSet
myConn.Open()
myDataAdapter = New OleDbDataAdapter(sql, myConn)
myConn.Close()
myDataSet = New DataSet()
myDataAdapter.Fill(myDataSet, strtable)
getdataview = New DataView(myDataSet.Tables(strtable))
End Function
Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim strConn As String
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("./") & "DB_51aspx/news.mdb"
myConn = New OleDbConnection(strConn)
Dim gjc As String
gjc = Page.Request("keyword")
sql = "select NewsID,Title,UpdateTime from News where Title like '%" & gjc & "%' or Content like '%" & gjc & "%' order by NewsID desc"
keyword.Text = gjc
Dim result As DataView = getdataview(sql, "newssearch")
searchresult.DataSource = result
searchresult.DataBind()
End Sub
</script>
<html>
<head>
<title>新闻搜索结果</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
</head>
<link href="style.css" type="text/css" rel="Stylesheet" />
<body>
<mynews:top runat="server" ID="top1" />
<table width="778px" border="0" align="center" cellpadding="0" cellspacing="6px">
<tr>
<td width="478px" valign="top">
<table width="100%" cellpadding="2px" cellspacing="0" style="border:1px solid #6699FF;">
<tr>
<td bgcolor="#6699FF">
您的关键词是:<font color="#FF6600"><b><asp:label ID="keyword" runat="server"/></b></font>
</td>
</tr>
<asp:repeater ID="searchresult" runat="server">
<itemtemplate>
<tr>
<td>
<a href="newshow.aspx?newsid=<%# container.DataItem("NewsID")%>" target="_blank"><%# container.DataItem("Title")%></a>(<%# container.DataItem("UpdateTime")%>)
</td>
</tr>
</itemtemplate>
</asp:repeater>
</td>
</tr>
</table>
</td>
<td width="300px" valign="top">
<mynews:special ID="Special1" runat="server"/>
</td>
</tr>
</table>
<mynews:footer runat="server" ID="end1" />
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -