Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 147861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T08:51:21+00:00 2026-05-11T08:51:21+00:00

The ‘RenderPartial()’ method in ASP.NET MVC offeres a very low level of functionality. It

  • 0

The ‘RenderPartial()’ method in ASP.NET MVC offeres a very low level of functionality. It does not provide, nor attempt to provide a true ‘sub-controller’ model *.

I have an increasing number of controls being rendered via ‘RenderPartial()’. They fall into 3 main categories :

1) Controls that are direct descendants of a specific page that use that page’s model

2) Controls that are direct descendants of a specific page that use that page’s model with an additional key of some type. Think implementation of ‘DataRepeater’.

3) Controls that represent unrelated functionality to the page they appear on. This could be anything from a banner rotator, to a feedback form, store locator, mailing list signup. The key point being it doesn’t care what page it is put on.

Because of the way the ViewData model works there only exists one model object per request – thats to say anything the subcontrols need must be present in the page model.

Ultimately the MVC team will hopefully come out with a true ‘subcontroller’ model, but until then I’m just adding anything to the main page model that the child controls also need.

In the case of (3) above this means my model for ‘ProductModel’ may have to contain a field for ‘MailingListSignup’ model. Obviously that is not ideal, but i’ve accepted this at the best compromise with the current framework – and least likely to ‘close any doors’ to a future subcontroller model.

The controller should be responsible for getting the data for a model because the model should really just be a dumb data structure that doesn’t know where it gets its data from. But I don’t want the controller to have to create the model in several different places.

What I have begun doing is creating a factory to create me the model. This factory is called by the controller (the model doesn’t know about the factory).

public static class JoinMailingListModelFactory {          public static JoinMailingListModel CreateJoinMailingListModel() {              return new JoinMailingListModel()             {                 MailingLists = MailingListCache.GetPartnerMailingLists();             };         }     }    

So my actual question is how are other people with this same issue actually creating the models. What is going to be the best approach for future compatibility with new MVC features?


  • NB: There are issues with RenderAction() that I won’t go into here – not least that its only in MVCContrib and not going to be in the RTM version of ASP.NET-MVC. Other issues caused sufficent problems that I elected not to use it. So lets pretend for now that only RenderPartial() exists – or at least that thats what I’ve decided to use.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T08:51:21+00:00Added an answer on May 11, 2026 at 8:51 am

    One approach I’ve seen for this scenario is to use an action-filter to populate the data for the partial view – i.e. subclass ActionFilterAttribute. In the OnActionExecuting, add the data into the ViewData. Then you just have to decorate the different actions that use that partial view with the filter.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 408k
  • Answers 408k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer The code is incomplete, but it looks like you're assigning… May 15, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer I believe that under IIS7 (which I am assuming you… May 15, 2026 at 6:43 am
  • Editorial Team
    Editorial Team added an answer -webkit-appearance: none; can be used to remove the select control's… May 15, 2026 at 6:43 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.