I have a link that opens a dialog to user to add it´s profile.
I want the data to be there on hidden fields
The controller calls this view but I am not sure how to populate my model in controller and then use the model in this view to set the values properties.
this is my controller and as you can see I am using ViewBag and I don´t want that.
public ActionResult EditUser()
{
try
{
MembershipUser membershipUser = Membership.GetUser(Request.QueryString["username"]);
ViewBag.user = membershipUser;
return PartialView();
}
catch (Exception e)
{
return Content("Error: " + e);
}
}
Could you please help me understand how to build my model and use it in my view?
Thanks a lot…
All you have to do is pass the model you’ve created into the call to the View/Partial View. So in your instance rather than calling:
you should use:
You just need to make sure that in your view you have a
@modeldeclaration at the top. It’ll be something like: