I am loving MVC but can't see to understand how your meant to implement User Controls. If I have a Multiple views each with shopping basket details how can I encapulate the shopping basket view and code so I don't have to return the basket data with each controller viewdata?
From this MSDN page:
A partial view enables you to define a view that will be rendered inside a parent view. Partial views are implemented as ASP.NET user controls (.ascx).
Write out your shopping cart view in a partial view. Within a ViewPage, you call Html.RenderPartial("PartialNameHere")
to render this to whatever spot on the page you called it from. Like views, you can have strongly-typed Partial Views so that you can pass in a Model of whatever type you choose.
Please note the following (also from the MSDN link above; emphasis mine):
When a partial view is instantiated, it gets its own copy of the ViewDataDictionary object that is available to the parent view. The partial view therefore has access to the data of the parent view. However, if the partial view updates the data, those updates affect only the partial view's ViewData object. The parent view's data is not changed.
You have to return basket data in each controller action that will return the view that use the basket user controll. But there are methods to avoid code repetition here. You can decorate the action method with custom ActionFilterAttribute that will inject the appropriate data in OnAxctionExecuted event, or you can add basket data to ViewData dictionary in base controller Initialize method and then access it in control with ViewData["magic-string"] or create extension method on HtmlHelper to avoid magic strings.
The other answers are exactly right, but there is a second option. You could render your partial view as a result of an AJAX call to a controller action dedicated to your partial view. That way your partial view just has to deal with a model that has data only it cares about.