How do I pass the model from the view Confirm to CareContro开发者_运维百科ller in URL.RouteURL?
View (Confirm)
<% using (Html.BeginForm())
{ %>
<%: Html.ValidationSummary(true) %>
<div class="editor-field">
<%: Html.CheckBoxFor(model => model.ConfirmOrder) %>
</div>
<% } %>
<%= Url.RouteUrl(new { controller = "care", action = "process"}) %>
CareController
public ActionResult Process(ConfirmViewModel model)
{
}
Thanks
Tim had the right idea. Here's your code sample updated. There are several overloads for the Html.BeginForm as the MSDN article points out. You just need to use the one you need.
<% using (Html.BeginForm("Process", "CareController" }))
{ %>
<%: Html.ValidationSummary(true) %>
<div class="editor-field">
<%: Html.CheckBoxFor(model => model.ConfirmOrder) %>
</div>
<% } %>
<input type="submit" value="Post">
You shouldn't be using Url.RouteUrl for this. That's what the Html.BeginForm is for. It's setup to submit your form to the controller. If you need to change what controller / action it's using then you can pass in additional parameters to Html.BeginForm (http://msdn.microsoft.com/en-us/library/system.web.mvc.html.formextensions.beginform.aspx). Url.RouteUrl will just return a string of the fully qualified URL that you're requesting.
精彩评论