Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

user controls and asp.net mvc

Here is one trivial question, that I am not sure how to handle. I need to display list of categories on every page, and to be able to choose items from a specific category to be displayed. I use asp.net MVC, and have chosen to create a user control that will display categories. My question is: what is the best approach to pass 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 like also to hear your opinion.

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

like image 560
Dragan Panjkov Avatar asked Dec 15 '25 21:12

Dragan Panjkov


2 Answers

I'm using mvc components, which replaced ascx user controls in preview 4.
Example: http://blog.wekeroad.com/blog/asp-net-mvc-preview-4-componentcontroller-is-now-renderaction/
So, you call components action from View, which then choose View to render. You can pass data in this call also.

like image 194
Hrvoje Hudo Avatar answered Dec 18 '25 09:12

Hrvoje Hudo


it is the mvc futures project. i will probably try this http://forums.asp.net/t/1303328.aspx. I need to render menu with categories.

like image 37
Dragan Panjkov Avatar answered Dec 18 '25 10:12

Dragan Panjkov



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!