dan_vitch dan_vitch -4 years ago 170
C# Question

ViewModel MVC 3

I am new to MVC. I am going through the following

I am on the portion where it calls for the following code

public ViewResult Edit(UserModel um)

if (!TryUpdateModel(um))
ViewModel.updateError = "Update Failure";
return View(um);

// ToDo: add persistent to DB.
return View("Details", um);

When I attempt to use ViewModel I receive an error:

"The name ViewModel does not exist in the current context."

Intellisense does not show ViewModel as an option.

Answer Source

ViewModel does not exist for a mvc 3 controller. I think what you are looking to use instead is the following:

ViewBag.UpdateError = "Update Failure";

Then in your view:

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download