MVC 3.0 Autocomplete

 JS:
    <link href="http://mikelai.blog.163.com/blog/@Url.Content("~/Content/Site.css")" rel="stylesheet" type="text/css" />
    <link href="http://mikelai.blog.163.com/blog/@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="http://mikelai.blog.163.com/blog/@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="http://mikelai.blog.163.com/blog/@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script src="http://mikelai.blog.163.com/blog/@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#complete").autocomplete({
            source:'/Home/Get'
            });
        });

    </script>
View:
@Html.TextBox("complete")
Controller:
        public JsonResult Get(string term)
        {
            var gets = new string[] {"a","bd","ec" };
            return Json(gets,JsonRequestBehavior.AllowGet);
        }
javascript

相關文章
相關標籤/搜索