ajaxasp.net-mvc-3formsdeserializationmodelbinder

MVC3 NuGet PagedList form data


I created a model that has 2 properties, a pagedlist of selectable templates and a paged list of selectable versions.

The idea is that the view will allow you to select multiple versions and templates so that when you post the form it will create new instances for each possible combination of the templates and versions selected.

The problem I have atm is dealing with the pagedlist from nuget. I read that it wasn't possible to post with a normal actionlink so I attempted a Ajax.Beginform with the pagedlist Next being a ajax.actionlink with a httpmethod of POST being set.

Unfortunately when it gets to my modelbinder specified for this model the controllercontext doesn't have anything in keys of the form.

Checkboxes look like this inside the ajax beginform section:

<table>
                    <tr>
                        <th>
                        </th>
                        <th>
                            <a href="/AppliedTemplates/Create">Product</a>
                        </th>
                        <th>
                            <a href="/AppliedTemplates/Create">Version</a>
                        </th>
                    </tr>
                        <tr>
                            <td>
                                <input type="checkbox" name="[0].ProductVersion_ID" id="ProductVersion_ID_1" value="1"/>

                            </td>
                            <td>
                                Availability Standard Edition for Windows
                            </td>
                            <td>
                                5.2
                            </td>
                        </tr>  
                        <tr>
                            <td>
                                <input type="checkbox" name="[1].ProductVersion_ID" id="ProductVersion_ID_2" value="2"/>

                            </td>
                            <td>
                                Availability Standard Edition for Windows
                            </td>
                            <td>
                                5.3
                            </td>
                        </tr>  
                        <tr>
                            <td>
                                <input type="checkbox" name="[2].ProductVersion_ID" id="ProductVersion_ID_3" value="3"/>

                            </td>
                            <td>
                                Availability Standard Edition for Windows
                            </td>
                            <td>
                                6.0
                            </td>
                        </tr>  
</table>

Am I looking in the wrong place to find this deserialized data in the modelbinder or am I doing something wrong with the html?

Thanks so much!


Solution

  • I was using the forms completely wrong. Form within a form is a no no. I made just one form and manipulated the returns with a IModelBinder implementation to include all the data I need.