[英]Passing list/model as parameter with @url.action
Is there a way to pass list as parameter for @url.action
or is there a better solution for this? 有没有一种方法可以将列表作为
@url.action
参数传递,或者有更好的解决方案?
Pseudo code: This doesn't pass anything, unless I define index for my model or list. 伪代码:除非我为模型或列表定义索引,否则不会传递任何内容。
@Url.Action("DeleteConfirmed", "Home", new { selectedids = /*model or list?*/ }, null)
I need to pass list or model to this: 我需要将列表或模型传递给它:
public ActionResult DeleteConfirmed(List<int> selectedids) {
//Code
return View("Index");
}
I join them as a string and then convert that back on the server; 我将它们作为字符串加入,然后将其转换回服务器。 this means selectedids would need to be a string on the server, which you would string split on comma and convert each value to
long
. 这意味着selectedids在服务器上需要是一个字符串,您可以在逗号上将其字符串拆分并将每个值转换为
long
。
@Url.Action("DeleteConfirmed", "Home", new { selectedids = String.Join(",", Model.IDS) })
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.