【发布时间】:2014-04-30 20:54:11
【问题描述】:
我的网络表单上有一个文本框。我想将此文本框与我的数据库表中的“名称”列绑定。我希望当用户在此文本框中键入字母时,然后根据与字母匹配的数据,建议将像任何其他搜索引擎一样在下拉列表中给出。我想在不使用 Ajax Autocomplete 扩展器或任何 Web 服务的情况下做到这一点。我尝试通过 Jquery 执行此操作,但我使用静态名称执行此操作。我希望从数据库中获取这些名称。请指导我该怎么做? aspx 页面-
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(function () {
var items = [
"Argo",
"Alex",
"Mike",
"Mark",
"Joseph",
"John",
"Alex",
"Marrie"
];
$("#TextBox1").autocomplete({
source: items
});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td>Name:</td>
<td>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
</tr>
</table>
</div>
</form>
</body>
</html>
【问题讨论】:
标签: c# javascript jquery autocomplete textbox