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 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
  • 3 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
Having worked for Java for 7 years I'm now moving into a project in
I am a web developer, have worked with PHP and .NET both. having over
After having worked in MVC for a few months, I'm back in a previously
I'm having problems with my ASP.NET web forms system. It worked on our test
I'm currently working with EF4 and asp.net mvc 3 and I'm certainly having some
My C++ is a little rusty having worked in Java and C# for the
I am having a problem with code that worked fine in .NET 2.0 but
I having an issue with the ASP.NET Treeview control. I create the treeview just
I have just started using StructureMap, having previously worked with Spring.Net. I love the

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.