TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
أماني مفيد
NA
142
17.2k
Autocomplete Text box MVC
Sep 3 2020 1:43 AM
i have auto complete text box
this is the script
<head>
<script src=
"https://code.jquery.com/jquery-1.10.2.min.js"
></script>
<link rel=
"stylesheet"
href=
"//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"
>
<script src=
"https://code.jquery.com/ui/1.12.1/jquery-ui.js"
></script>
</head>
<body>
<input id=
'CountryName'
/>
<span id=
'CountryID'
></span>
var
data2;
$.ajax({
url:
'/Home/GetRecord'
,
dataType:
"json"
,
data: data2,
success:
function
(data) {
data2 = data;
},
error:
function
(xhr, status, error) {
alert(
"Error"
);
}
});
$(
'#CountryName'
).autocomplete({
data: { search: $(
"#searchInput"
).val() },
source:
function
y(request, response) {
response($.map(data2,
function
(item) {
return
{
label: item.t,
value: item.t
}
}));
}
,
select:
function
(e, ui) {
e.preventDefault();
$(
this
).val(ui.item.label);
$(
'#CountryID'
).html(ui.item.value);
}
});
</script>
this is the controller
[HttpGet]
public
JsonResult GetRecord(
string
prefix)
{
DataSet dst =
new
DataSet();
dst.Tables.Add(op.GetName(prefix));
List<DataSearch> searchlist =
new
List<DataSearch>();
foreach
(DataRow dr
in
dst.Tables[0].Rows)
{
searchlist.Add(
new
DataSearch
{
t = dr[
"ARTICAL_NAME"
].ToString()
});
}
return
Json(searchlist , JsonRequestBehavior.AllowGet);
}
when i click in text box that ajax call not work , i call it from url like this https://localhost:44330/home/GetRecord?prefix=t
and the result
[{"t":"test"},{"t":"test from it "},{"t":"table "}] and appear in new page
any help to make result appear as dropdown when i start write inside textbox
Reply
Answers (
2
)
ADO.net Entity Data Model template is missing in vs 2019
How can I Use Addrenge Entity how to install relevant DLL for Addrenge