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.3k
Autocomplete Text box MVC
Aug 30 2020 6:33 AM
i have a autocomplete text box
this is the controller
[HttpPost]
public ActionResult 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
{
label = dr["ARTICAL_NAME"].ToString(),
val = dr["ARTICL_ID"].ToString()
});
}
return Json(searchlist);
}
and this is the Ajax
$(document).ready(function () {
SearchText();
});
function SearchText() {
$("#MyId").autocomplete({
source: function (request, response) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: '/Home/GetRecord',
data: "{'prefix':'" + document.getElementById('MyId').value + "'}",
dataType: "json",
success: function (json) {
//alert( json[0].label);
response(json)
{
//alert( json[0].label);
$("#MyId").append($("<option></option>").val(json[0].label).html(json[0].label)); }
},
error: function (result) {
alert("No Match");
}
});
}
});
}
</script>
i want resutl appaer as drop down list
any help ?
Reply
Answers (
4
)
Columns and rows not adding dynamicaly in C# Datatable
how to insert video to an xampp database php my admin