简体   繁体   中英

passing a Guid from a view back to corresponding controller action

<div class="col1">
@foreach (var item in Model.ListApplications.Select((model) => new { model }))
{
    <div class="col1">
        <fieldset>
            <p><span class="bold-text">Application ID: </span>@item.model.ApplicationId</p>

            <p><span class="bold-text">First Name: </span>@item.model.FirstName</p>

            <p><span class="bold-text">Last Name: </span>@item.model.LastName</p>

            <p><span class="bold-text">Programme Name: </span>@item.model.ProgrammeDesc</p>

            <p><input id="submit-button" class="form-submit-button" type="submit" value="continue application" /></p>                        
        </fieldset>
    </div>
}   
</div>

The code above is found on a page for selecting previously started applications that a user can select to continue filling in. When the submit button is clicked, the Application Id for the specific application needs to be returned to this controller action:

    [HttpPost]
    [ValidateAntiForgeryToken]
    public ActionResult PreviousApplications(ListApplicationViewModel model)
    {
        return RedirectToAction("PersonalDetails");
    }

A user could potentially have multiple applications.

How do I go about implementing this?

Did you use @Html.Hidden() or @Html.HiddenFor() ? It works me always very well for example

@Html.HiddenFor(@item.model.ApplicationId)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM