I'm very new to ASP.NET so I may not be wording this correctly but what I am trying to do is show a list of data say on my home page from my database. Now normally I would do all the usual stuff like write some SQL in the controller and then do a foreach loop in the View. But how would I do this for something I want to show on multiple pages like a sidebar of the latest news items?
If anyone can give me some examples of this in use (downloadable solutions would be great) it'd be much appreci开发者_开发知识库ated. Thanks.
You should create an action and view that render that list alone, then render the action in your Master / Layout page by calling Html.RenderAction
.
Also you could create Base controller class, which will fetch general data for your site: news, menu.
精彩评论