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

  • Home
  • SEARCH
  • 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 3678932
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:24:00+00:00 2026-05-19T03:24:00+00:00

Having worked with .net in both winforms and ASP.net for a few years I

  • 0

Having worked with .net in both winforms and ASP.net for a few years I am now starting to get into MVC (a little late I know). One major confusion for me is the concept of reusable ‘components’, similar to the concept of a usercontrol in webforms.

For example, I would like to have a number of ‘widgets’ within the members area of my site, one of which is the details of the logged in users account manager. I can create this as a partial however when the page loads the data needs to be passed in as part of the ViewModel / View Data. I would like to use this widget in a number of different sections which would then mean that I need to put the code to pass the data in into a number of different controllers. This seems to violate the DRY principle, or am I missing something here? I would ideally like everything to be encapsulated within the 1 partial which can then be used in any page.

  • 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. Editorial Team
    Editorial Team
    2026-05-19T03:24:01+00:00Added an answer on May 19, 2026 at 3:24 am

    You can go three ways:

    1) For simple controls without much logic, you can create new instance of the custom view model for the control:
    Html.RenderPartial(“YourControl”, new YourControlViewModel () { Param1=”value1″, Param2 = Model.AnotherValue });

    2) If you need some back end logic for the control, you can use
    Html.RenderAction(“ActionName”, “SomeControllerName”, RouteValuesDictionary);
    It will call standard controller action, use the view, and insert the resulting output back to the page. You can add [ChildActionOnly] atribute to the controller method to ensure that the method will be available only from the Html.RenderPartial. It is slightly violating the MVC principle (view shouldn’t call controller), but its great for widgets, and it is used in the Ruby on Rails world without much issues. You can check great article from Haacked

    3) Create custom html helper for tasks like custom date formatting, calculating etc..

    In your case, I would choose the number two.

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

Sidebar

Related Questions

Having worked with Classic ASP for about 2 years now by creating a few
I am a web developer, have worked with PHP and .NET both. having over
So, I have an asp.net mvc app that is being worked on by multiple
I worked for a company that had both Java and .NET implementations of an
I'm relatively familiar with the concepts of DI/IOC containers having worked on projects previously
Having programmed through emacs and vi for years and years at this point, I
I am having an issue related to executing a .Net dll from a classic
I was having a problem with my .NET 1.1 website which was hard to
Having a friendly debate with a co-worker about this. We have some thoughts about
I was having a conversation with a co-worker and the subject of null came

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.