USE [Demo]
GO
SET
ANSI_NULLS
ON
QUOTED_IDENTIFIER
ANSI_PADDING
CREATE
TABLE
[dbo].[tblFlightInformation](
[FlightId] [
int
]
NOT
NULL
,
[FlightDestination] [
varchar
](50)
COLLATE
SQL_Latin1_General_CP1_CI_AS
[FlightLeaveTime] [datetime]
[FlightReturnTime] [datetime]
CONSTRAINT
[PK_tblFlightInformation]
PRIMARY
KEY
CLUSTERED
(
[FlightId]
ASC
)
WITH
(IGNORE_DUP_KEY =
OFF
[
INSERT
INTO
dbo.tblFlightInformation (FlightId, FlightDestination, FlightLeaveTime, FlightReturnTime)
VALUES
(1,
'India'
'2011-11-12 19:30:00'
'2011-11-12 23:00:00'
(2,
'Italy'
'2011-11-13 06:00:00'
'2011-11-13 12:45:00'
(3,
'Singapore'
'2011-11-13 04:10:00'
'2011-11-14 01:15:00'
(4,
'America'
'2011-12-01 09:20:00'
'2011-12-06 08:50:00'
(5,
'Saudi Arabia'
'2011-12-10 23:10:00'
'2011-12-13 19:10:00'
[WebMethod]
public
List<
string
> LoadDestinationInformation(
prefixText)
{
using
(SqlConnection conn =
new
SqlConnection())
conn.ConnectionString = ConfigurationManager.ConnectionStrings[
"FlightInformation"
].ConnectionString;
(SqlCommand cmd =
SqlCommand())
cmd.CommandText =
"select FlightDestination from tblFlightInformation where "
+
"FlightDestination like @FlightDestination + '%'"
;
cmd.Parameters.AddWithValue(
"@FlightDestination"
, prefixText);
cmd.Connection = conn;
conn.Open();
> FlighDestination =
>();
(SqlDataReader sdr = cmd.ExecuteReader())
while
(sdr.Read())
FlighDestination.Add(sdr[
"FlightDestination"
].ToString());
}
conn.Close();
return
FlighDestination;
<%@ Page Title=
"Home Page"
Language=
"C#"
AutoEventWireup=
"true"
CodeFile=
"Default.aspx.cs"
Inherits=
"_Default"
%>
<%@ Register Assembly=
"AjaxControlToolkit"
Namespace=
TagPrefix=
"ajax"
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head id=
"Head1"
runat=
"server"
<title>Ajax AutoCompleteExtender without Webservice</title>
</head>
<body>
<form id=
"form1"
<ajax:ToolkitScriptManager ID=
"ScriptManager1"
EnablePageMethods =
/>
<div>
<asp:TextBox ID=
"txtCountry"
AutoPostBack=
"True"
></asp:TextBox>
<ajax:AutoCompleteExtender ID=
"AutoCompleteExtender1"
TargetControlID=
MinimumPrefixLength=
"1"
EnableCaching=
CompletionSetCount=
CompletionInterval=
"1000"
ServiceMethod=
"LoadDestinationInformation"
ServicePath=
"WebServiceFlightInformation.asmx"
</ajax:AutoCompleteExtender>
</div>
</form>
</body>
</html>
Richard Mueller edited Revision 2. Comment: Replace rgb values in HTML with color names to restore colors