在回复的帮助下,我将代码更改为
@Html.TextBoxFor(per => per.Hospital, new { style = "width:220px", @maxlength = "50", data_autocomplete = Url.Action("HospitalList", "Person") })
我的jQuery是
$(document).ready(function () {        
    $('input[data_autocomplete]').each(function () {
        var url = $(this).data('autocomplete');
        $(this).autocomplete({
            source: function (request, response) {
                $.getJSON(url, {
                    term: request.term
                }, response);
            }
        });
    });
});
并创建了一个新的 Action 结果
 public ActionResult HospitalList(string term)
    {
        List<string> result = new List<string>();
        result.Add("Hospital 1");
        result.Add("NYUMC");
        result.Add("Christ");
        result.Add("Bellevue");
        result.Add("NewYork-Presbyterian");
        result.Add("North Central Bronx Hospital");            
        return Json(result , JsonRequestBehavior.AllowGet);
    }  
现在我要去哪里wromg。我只看到一个文本框,没有自动完成的行为。我是否应该包含任何 jquery 库以使其正常工作