0

I'm currently looking for a good way to implement navigation between pages (without using any kind of dialogs) - particularly where a page is shared by more than one other page.

Example

There are three pages:

  • ProductEdit
  • OrderListItem
  • ProductList

The ProductEdit page can be navigated to from both the OrderItemList and the ProductList pages.

The ProductEdit page has a cancel and an update action for it. When the user clicks one of these actions I need control to return back to the page it came from.

Multiple Levels

Any ideas on the best way to implement this. I also need to support this working at more than one level.

Related Posting This is all MVC3 related but is very similar to another StackOverflow posting: Web page navigation

Many Thanks!

Community
  • 1
  • 1
dubs
  • 6,511
  • 4
  • 19
  • 35
  • Are you fimilar with the ASP.Net-MVC structure? What is the problem **exactly**? – gdoron Feb 05 '12 at 12:00
  • Fairly familiar with MVC. How would I know where to return back to when arriving on the ProductEdit page? I'm familiar with the url referrer but this approach wouldn't work in multi-level senarios so I think that's UrlReferrer is out. – dubs Feb 05 '12 at 12:05

1 Answers1

0

You can use the ProductEdit Page as partial view , and then check the ViewBag.Title to know in which page it came from. For example:

In OrderListItem Page :

@{ ViewBag.Title = "OrderListItem";}
@Html.Partial("ProductEdit");

and same in ProductList Page. In ProductEdit Page check :

If ( ViewBag.Title = "OrderListItem")

//send value to your control with the title as paramter...

TwTw
  • 551
  • 4
  • 15
  • Thanks for your comments. I see what you are saying but this would tightly couple the ProductEdit page to all the other pages that request it. I should point out that I wish the ProductEdit page to be a separate page (i.e. not a Partial). Perhaps, prior to loading up the ProductEdit page I could store (either ViewBag or Model) the return action, controller and route data). Could this work? – dubs Feb 05 '12 at 13:30
  • I don't really understand you. Why can't you implement @Html.Partial("ProductEdit") only in the Required pages? – TwTw Feb 05 '12 at 14:06
  • Because I want to show the ProductEdit view in a separate page. My understanding of Html.Partial is that it will render html in the containing view - this isn't something that I want to do - I wish to keep the ProductEdit view as a separate page that the user can navigate to. I hope this makes it clear - sorry for any confusion. – dubs Feb 05 '12 at 16:21