User Controls and asp.net mvc

Here is one trivial question that I'm not sure how to handle. I need to display a list of categories on each page and be able to select items from a specific category to display. I am using asp.net MVC and decided to create a user control that will display categories. My question is: what is the best approach for passing data to a user control. I already found some information in these blog posts:

http://weblogs.asp.net/stephenwalther/archive/2008/08/12/asp-net-mvc-tip-31-passing-data-to-master-pages-and-user-controls.aspx

http://blog.matthidinger.com/2008/02/21/ASPNETMVCUserControlsStartToFinish.aspx

I would also like to hear your opinion.

PS. I would love to hear Jeff's opinion, especially because of his experience with UC on Stackoverflow

+3
source share
2 answers

I use mvc components that replaced the ascx user elements in preview 4.
Example: http://blog.wekeroad.com/blog/asp-net-mvc-preview-4-componentcontroller-is-now-renderaction/
So you call the action of the components from the view, which then selects the "View" for rendering. You can also transfer data in this call.

+2
source

This is a mvc futures project. I will probably try this http://forums.asp.net/t/1303328.aspx . I need to display a menu with categories.

+1
source

Source: https://habr.com/ru/post/1696427/


All Articles