使用Json在MVC4中自动完成 [英] Autocomplete in MVC4 using Json

查看:78
本文介绍了使用Json在MVC4中自动完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨......我是mvc的初学者。我试图在mvc4 razor中设置自动完成文本框..我的项目通过使用实体框架工作模型完成...我想自动完成我的文本框引用所有列值的表..我的问题是我只获得单列值。我想知道如何在自动完成部分中从文本框中的表(所有列值)中获取所有值。请帮我解决这个问题。谢谢





我的代码是:



public JsonResult Getbusiness(string术语)

{

MvcApplication1Entities1 db = new MvcApplication1Entities1();

List< string>业务;

{

business = db.tblBusinessCategories.Where(x => x.BusinessName.StartsWith(term))

。选择(y => y.BusinessName)。ToList();

}

返回Json(business,JsonRequestBehavior.AllowGet);

}

解决方案

//来这里

http://csharp-video-tutorials.blogspot.in/2015/06/autocomplete-textbox-using-jquery-in.html [< a href =http://csharp-video-tutorials.blogspot.in/2015/06/autocomplete-textbox-using-jquery-in.htmltarget =_ blanktitle =New Window> ^

Hi..i am beginner in mvc. am trying to set autocomplete a textbox in mvc4 razor.. my project done by using entity frame work model... i want to autocomplete my textbox that refers from a table of all columns values.. my issue is am only getting single column values. i want to know how to get all value from a table( all columns values) in textbox during autocomplete section. kindly help me to fix this. thanks


my code is:

public JsonResult Getbusiness(string term)
{
MvcApplication1Entities1 db = new MvcApplication1Entities1();
List<string> business;
{
business = db.tblBusinessCategories.Where(x => x.BusinessName.StartsWith(term))
.Select(y => y.BusinessName).ToList();
}
return Json(business, JsonRequestBehavior.AllowGet);
}

解决方案

//Go here
http://csharp-video-tutorials.blogspot.in/2015/06/autocomplete-textbox-using-jquery-in.html[^]


这篇关于使用Json在MVC4中自动完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆