How are ViewUserControls meant to be used?

Last post 01-07-2008 1:17 AM by robconery. 2 replies.

Sort Posts:

  • How are ViewUserControls meant to be used?

    01-03-2008, 6:32 PM
    • Member
      point Member
    • uooq
    • Member since 01-03-2008, 11:23 PM
    • Posts 1

    I'm sorry if this is a really silly question, Embarrassed 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   :)

  • Re: How are ViewUserControls meant to be used?

    01-03-2008, 7:23 PM
    • Contributor
      4,318 point Contributor
    • tgmdbm
    • Member since 12-17-2007, 9:08 AM
    • Posts 876
    • ASPInsiders
      TrustedFriends-MVPs

    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.
     

  • Re: How are ViewUserControls meant to be used?

    01-07-2008, 1:17 AM
    • Participant
      846 point Participant
    • robconery
    • Member since 02-23-2005, 5:16 PM
    • Posts 192

    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/

     

Page 1 of 1 (3 items)