相关疑难解决方法(0)

ASP.NET MVC - 使用ViewData将Json String传递给View

我正在尝试使用ViewData将Json传递给我的View

调节器

ViewData("JsonRegionList") = Json(RegionService.GetActiveRegions())
Run Code Online (Sandbox Code Playgroud)

视图

        $("input#UserRegion").autocomplete({
                source:"<%: ViewData("JsonRegionList").ToString %>",
                minLength: 3,
Run Code Online (Sandbox Code Playgroud)

但我遇到的问题是输出源看起来像

        $("input#UserRegion").autocomplete({
                source:"System.Web.Mvc.JsonResult",
                minLength: 3,
Run Code Online (Sandbox Code Playgroud)

这显然是不对的.我错过了什么基本的东西?

json viewdata jsonresult asp.net-mvc-2

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

asp.net-mvc-2 ×1

json ×1

jsonresult ×1

viewdata ×1