0

I have a view called DetailsLane and another AddItem. When the DetailsLane is rendered, it returns a model class with properties. The AddItem action is inside of the same controller, but when I finish whatever I had to do inside of this action, I can't re-render the DetailsLane to update the view.

The view is called first time: it works!

public ActionResult DetailsLane(int? id, int? IdInstance)
{
    return View(get(IdInstance, id));
}

public ActionResult AddLine(FormCollection collection)
{
      // I did my stuff in here, and I want to return the initial View or,
      // validate something from the collection.
      return DetailsLane(val, val);     // doesn't work!
}

1 Answer 1

2

You want to use RedirectToAction and you can pass arguments as shown here

public ActionResult AddLine(FormCollection collection)
{
  // I did my stuff in here, and I want to return the initial View or,
  // validate something from the collection.
  return RedirectToAction("DetailsLane", new { id = val1, IdInstance = val2 });
}

note that id and IdInstance match the parameter names in your DetailsLane action method.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.