I am still learning and not sure how to do this, I have in my controller:
[HttpGet]
public ActionResult Detail(int userId)
{
var user = ZincService.GetUserForId(userId);
UserDetailViewModel userDetail = new UserDetailViewModel();
userDetail.UserId = userId;
userDetail.Email = user.Email;
userDetail.Firstname = user.Firstname;
userDetail.Surname = user.Surname;
return View(userDetail);
}
[HttpGet]
public ActionResult ChangeEmailAddress()
{
return View();
}
In my Detail view:
<div class="section _100">
<%: Html.LabelFor(model => model.Email)%>
<div>
<%: Model.Email %>
<%: Model.UserId %>
</div>
<div>
<%: Html.ActionLink("Change Email Address", "ChangeEmailAddress", "User", new { area = "Admin", @id = Model.UserId, @email = Model.Email, @name = Model.Firstname }, 0) %>
<%: Html.ValidationMessageFor(model => model.Email)%>
</div>
</div>
I just want to go from here in the view to another view(ChangeEmailAddress) where the user can actually change his email from old to new?
Thanks
Why did you put 0 as last argument of the ActionLink? It should be null.
Now your
ChangeEmailAddressaction could take the model as parameter:Then you should define the corresponding
ChangeEmailAddress.aspxview which will be rendered by this controller action and strongly typed to your view model.But a better approach is to send only the user id in the request and then retrieve the actual user object using this id:
and then: