如何使用ajax.actionlink获取formcollection [英] How to get formcollection using ajax.actionlink
本文介绍了如何使用ajax.actionlink获取formcollection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有以下代码的控制器:
I have a controller with the codes like this:
[AcceptVerbs("POST")]
public ActionResult Create(FormCollection collection)
{
//why is that the collection is null?
}
我正在使用ajax.actionlink调用此操作.
I am calling this action using the ajax.actionlink.
我的问题是集合为null,这与我是否使用commit(input)按钮不同 表单集合具有值.
my problem is the collection is null, unlike if i use the submit(input) button the formcollection has values.
推荐答案
FormCollection has a default binder associated with it which always initializes the collection and you should never get null
. It is more likely that you have an empty collection when using Ajax.ActionLink in contrast to when using a form submit button. This is because the ActionLink method doesn't POST any form values when it performs the AJAX request.
这篇关于如何使用ajax.actionlink获取formcollection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文