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
jothi kumar
1.6k
107
56.3k
how to search in mvc5
Aug 22 2014 1:52 AM
hi to all,
Here i done searching for autocomplete textbox .
Let us consider now i have total pages 10, now i filter respective record in table then i will filter as per given information and that have 5 pages . if i click 2 nd from filtering record pages then total page should be refreshing again i got 10 pages
Here i used this code:
In controller:
public JsonResult SearchAutoCompleter(string term ,string Branchlist,int? page)
{
var myObjects = (from o in db.Branches
join cou in db.Country on o.Country_Id equals cou.Country_Id
where o.Branch_Name.Contains(term)||cou.Country_Name.Contains(term)
select new
{
label = o.Branch_Name,o.Country_Id
}).Distinct().Take(3);
ViewBag.term = myObjects;
return Json(myObjects, JsonRequestBehavior.AllowGet);
}
In index using Ajax function:-
<script type="text/javascript" src="~/Scripts/jquery-ui-1.10.4.min.js"></script>
<script type="text/javascript" src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$("#autocomplete").autocomplete({
source: "@Url.Action("SearchAutoCompleter","Branch")",
messages: {
noResults: 'no result found',
results: function () { }
}
});
});
</script>
Design:-
@Html.TextBox("SearchName", ViewBag.branch_Name as string, new { @id = "autocomplete" })
if u not understand kindly let me know. Here i want to set paging for filtered record
Reply
Answers (
1
)
Export and Import data from ASP.net To tally ERP
Asp.net bootstrap