How to get formcollection using ajax.actionlink
Asked Answered
N

2

0

I have a controller with the codes like this:

[AcceptVerbs("POST")]
public ActionResult Create(FormCollection collection)
{
    //why is that the collection is null?
}

I am calling this action using the ajax.actionlink.

my problem is the collection is null, unlike if i use the submit(input) button the formcollection has values.

Nagano answered 11/10, 2009 at 8:58 Comment(0)
K
1

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.

Kurman answered 11/10, 2009 at 9:41 Comment(0)
S
0

You need to use Ajax.BeginForm

Scurlock answered 2/11, 2009 at 15:17 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.