Reputation:
So I have 3 views, a controller and one model. (just an example) The first view sets the user first name and last name. Which gets posted back to the controller, and I can see the data in the view-model. The controller then calls the second view sets the email (I can call the data from view 1). The third view shows all of the data (the original stuff from view 1 is no longer there)
@Html.DisplayFor(m => m.FirstName)
@Html.DisplayFor(m => m.LastName)
@Html.DisplayFor(m => m.Email)
Do you think creating a static singleton model would work in the controller? or should I be using TempData
EDIT: sorry I forgot about my controller
Would my GET methods in my controller need a parameter?
[HttpGet]
public virtual ActionResult SignUp1(model m)
{
return View(m)
}
Upvotes: 0
Views: 133
Reputation: 7591
you can call into another view using @Html.Partial("view name", object)
if you want to preform logic you can call another controller action with @Html.Action("action", "controller", object)
. then it's just like any other controller action. typically calling actions from a view are decorated with [ChildActionOnly]
Upvotes: 1
Reputation: 13706
Static is a bad idea for web pages, because it is not inherently thread-safe (see here). That means that you'll get really bizarre behavior if you have two or more people using it at once.
I'm not sure why you're even considering doing it this way - is there some specific reason you're thinking about it? The proper way to do it would be to post the model back to each controller action from each view, populating more data each time. Alternatively, you could post back to the same action, and then return the appropriate view based on which fields are missing from the model (and the display if none are).
Upvotes: 0