views:

644

answers:

2

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.

+1  A: 

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.

Darin Dimitrov
A: 

You need to use Ajax.BeginForm try this link to get more information link text

Peter Marshall