我如何使用控制器中定义的数组列表 [英] How can i use the array list defined in controller

查看:126
本文介绍了我如何使用控制器中定义的数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友们,

我已经使用c#定义了数组列表.在该数组列表中,我定义了两个列表.
我必须使用索引页面中的两个列表.我怎么能做到呢?

代码:

ArrayList list = new ArrayList();
list.Add(list1);
list.Add(list2);

我必须在ajax成功函数中使用list1和list2.
我正在得到清单的长度.但是我该如何获取
列表(list1和list2)

问候,
Srinivas

Hi friends,

I have defined the array list using c#. In that array list i have defined two lists.
I have to use the two lists in the index page. How can i able to that.

Code:

ArrayList list = new ArrayList();
list.Add(list1);
list.Add(list2);

I have to use the list1 and list2 in ajax success function.
I am getting the length of the list. But how can i get the
lists(list1 and list2)

Regards,
Srinivas

推荐答案

如果您正在使用AJAX,则应从控制器操作方法中返回JsonResult:

http://msdn.microsoft.com/zh-cn/library/system.web.mvc.jsonresult%28v = vs.108%29.aspx [
If you''re using AJAX, you should return a JsonResult from your controller action method:

http://msdn.microsoft.com/en-us/library/system.web.mvc.jsonresult%28v=vs.108%29.aspx[^]

Assign your Array to the Data property of the JsonResult:

var result = new JsonResult { Data = list }

return result;


这篇关于我如何使用控制器中定义的数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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