I'm sorry if this is a really silly question, [:$] but I'm having a hard time grokking what the right usage of a ViewUserControl looks like. Does one invoke the RenderView from a controller? If so, where is the parent page that the ViewUserControl is embedded
in? Or, should you put RenderView into the ASPX of a ViewPage itself?
I can make the thing render in any number of different ways from different places, but I'm not clear on what the right MVC model is for this situation. I've read the long thread on the ".. very complex page with many MVC modules..." but I'm thinking of
a simpler scenario: Let's suppose you have three or four different views that you want to compose into a page? Is this the right scenario for a ViewUserControl? If so, where would you reference the control itself?
Also, are there any working examples posted that use ViewUserControls?
Now repeat the above question but swap in Master Page/ViewContentPage :)
Ok, the Controller should contain no logic other than where to get the data from, which view to render, and how to pass the data to the view.
The view is solely responsible for rendering the view, and so by extension, responsible for displaying any "sub views". So any ViewUserControls belong here.
However, a lot of the time the UI is customisable, ie, this user was the weather control, and this user has the stock control. And the information regarding which user has which controls is stored in the database and so the controller is now concerned about
something other than the entities being acted upon.
To be perfectly honest i don't know the best way to organise this. It would be good if someone could write a good blog post on this.
uooq
0 Points
1 Post
How are ViewUserControls meant to be used?
Jan 03, 2008 10:32 PM|LINK
I'm sorry if this is a really silly question, [:$] but I'm having a hard time grokking what the right usage of a ViewUserControl looks like. Does one invoke the RenderView from a controller? If so, where is the parent page that the ViewUserControl is embedded in? Or, should you put RenderView into the ASPX of a ViewPage itself?
I can make the thing render in any number of different ways from different places, but I'm not clear on what the right MVC model is for this situation. I've read the long thread on the ".. very complex page with many MVC modules..." but I'm thinking of a simpler scenario: Let's suppose you have three or four different views that you want to compose into a page? Is this the right scenario for a ViewUserControl? If so, where would you reference the control itself?
Also, are there any working examples posted that use ViewUserControls?
Now repeat the above question but swap in Master Page/ViewContentPage :)
tgmdbm
Contributor
4392 Points
883 Posts
ASPInsiders
MVP
Re: How are ViewUserControls meant to be used?
Jan 03, 2008 11:23 PM|LINK
Ok, the Controller should contain no logic other than where to get the data from, which view to render, and how to pass the data to the view.
The view is solely responsible for rendering the view, and so by extension, responsible for displaying any "sub views". So any ViewUserControls belong here.
However, a lot of the time the UI is customisable, ie, this user was the weather control, and this user has the stock control. And the information regarding which user has which controls is stored in the database and so the controller is now concerned about something other than the entities being acted upon.
To be perfectly honest i don't know the best way to organise this. It would be good if someone could write a good blog post on this.
robconery
Participant
852 Points
195 Posts
Re: How are ViewUserControls meant to be used?
Jan 07, 2008 05:17 AM|LINK
Did you say "good long blog post"... oh dear. You're egging me on aren't you :).
And here I was thinking that I might get some sleep tonite :)
http://blog.wekeroad.com/2008/01/07/aspnet-mvc-using-usercontrols-usefully/