开发者

How to password model from view to controller in URL.RouteURL

开发者 https://www.devze.com 2023-04-01 21:36 出处:网络
How do I pass the model from the view Confirm to CareContro开发者_运维百科ller in URL.RouteURL?

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号