以兩個頁面做出類似奇摩搜尋的功能
以兩個頁面做出類似奇摩搜尋的功能
ajax.js
































































Default.aspx 搜尋頁面
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>未命名頁面</title>
<script type="text/javascript" src="JS/ajax.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
//秀出結果 -來自Process.aspx的 dvResult
function Fill(val,id)
{
document.getElementById(id).value=val;
ClearRequest();
}
//清空結果
function Vanish()
{
ClearRequest();
}
</script>
</head>
<body style="font-family: Tahoma; font-size: smaller;">
<form id="form1" runat="server">
<div>
<table>
<tr>
<th>
</th>
</tr>
<tr>
<td>
搜尋:<asp:TextBox ID="txtSearchText" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<div id="dvtxtSearchText" style="width: 100%">
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>未命名頁面</title>
<script type="text/javascript" src="JS/ajax.js" language="javascript"></script>
<script type="text/javascript" language="javascript">
//秀出結果 -來自Process.aspx的 dvResult
function Fill(val,id)
{
document.getElementById(id).value=val;
ClearRequest();
}
//清空結果
function Vanish()
{
ClearRequest();
}
</script>
</head>
<body style="font-family: Tahoma; font-size: smaller;">
<form id="form1" runat="server">
<div>
<table>
<tr>
<th>
</th>
</tr>
<tr>
<td>
搜尋:<asp:TextBox ID="txtSearchText" runat="server" Width="200px"></asp:TextBox>
</td>
</tr>
<tr>
<td>
<div id="dvtxtSearchText" style="width: 100%">
</div>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default.aspx.vb











Process.aspx 回傳結果頁面
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Process.aspx.vb" Inherits="Process" %>
<html >
<body>
<div id="dvResult" style=" border-right: dimgray 1px solid; border-top: dimgray 1px solid; border-left: dimgray 1px solid; border-bottom: dimgray 1px solid;" runat="server">
</div>
</body>
</html>
<html >
<body>
<div id="dvResult" style=" border-right: dimgray 1px solid; border-top: dimgray 1px solid; border-left: dimgray 1px solid; border-bottom: dimgray 1px solid;" runat="server">
</div>
</body>
</html>
Process.aspx.vb











































參考至:http://www.codeproject.com/KB/aspnet/ASP.NET___AJAX.aspx