jeudi 2 avril 2015

MVC how to pass the updated Model back to a controller through an Html.ActionLink

So I have the following view in MVC4:



@model ViewModel

@section Sidebar
{
<ul style="margin-left:-20px">
...
<li>
@Html.ActionLink(@menuItem.Name, @menuItem.ActionName, @menuItem.ControllerName, @Model, new { id = @menuItem.Name + "MenuItemId", style = "font-weight: bold;", @class = "loading" })
</li>
...
</ul>
}

@using (Html.BeginForm())
{
<article class="widget widgetFullPage" data-role="collapsible" data-collapsed="true">
<h2 id="Details">GENERAL INFORMATION</h2>
<table>
<tr id="Row1" style="background-color: #FFFFFF;">
<td id="VarOneId" style="padding-bottom: 10px; padding-top: 20px; width: 300px">
@Html.TextBoxFor(x => x.VarOne, null, new { style = "width:100px;" })
</td>
</tr>
...
...
...
<tr id="RowX">
<td>
<input value=" " class="nextbutton loading" type="submit" id="NextButton" />
</td>
</tr>
</table>
</article>
}


The Submit button in the form works just fine, but I also want to pass the updated model (whatever the user has already typed) through the Html.ActionLink to a different controller in the Sidebar section above, when the user clicks on the sidebar link instead of the submit button.


What I have seems to only pass back the Model with data that's initially passed into the View, not the updated values from the page. What would I need to do to get the updated model and pass that back through the ActionLink?


Aucun commentaire:

Enregistrer un commentaire