Language: C#
Implement AJAX in MVC (the Controller)
// // GlossaryController.cs public ActionResult Index() { return View(Models.Term.SelectAll()); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index(FormCollection collection) { // used by non-AJAX form string _SearchTerm; _SearchTerm = collection["SearchTerm"]; // don't indicate the partial here // the view will call it return View(Models.Term .Where(x => x.Term.Contians(_SearchTerm))); } [AcceptVerbs(HttpVerbs.Post)] public ActionResult Index2(FormCollection collection) { // used by AJAX form string _SearchTerm; _SearchTerm = collection["SearchTerm"]; // you must indicate the partial here // it's all you want to render return View("Search", Models.Term .Where(x => x.Term.Contians(_SearchTerm))); }
Tags:
Report Abuse
Subscribe
Discuss
What's new
What is it
New Snippet
Recent Snippets
My Snippets
Web Code
Search

